Update unit test for bug 312.
Now the test verify if is possible connect more then 500 signals, if the signals was disconnected.
Reviewer: Hugo Parente Lima <hugo.pl@gmail.com>
Luciano Wolf <luciano.wolf@openbossa.org>
This commit is contained in:
parent
551f6b9c72
commit
1217b7df39
1 changed files with 23 additions and 0 deletions
|
|
@ -2,8 +2,16 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
import sys
|
||||||
from PySide.QtCore import QObject, SIGNAL
|
from PySide.QtCore import QObject, SIGNAL
|
||||||
|
|
||||||
|
class Dummy(object):
|
||||||
|
def __init__(self, parent):
|
||||||
|
self._parent = parent
|
||||||
|
|
||||||
|
def callback(self):
|
||||||
|
self._called = True
|
||||||
|
|
||||||
class MultipleSlots(unittest.TestCase):
|
class MultipleSlots(unittest.TestCase):
|
||||||
def myCB(self):
|
def myCB(self):
|
||||||
self._count += 1
|
self._count += 1
|
||||||
|
|
@ -17,6 +25,21 @@ class MultipleSlots(unittest.TestCase):
|
||||||
o.emit(SIGNAL("fire()"))
|
o.emit(SIGNAL("fire()"))
|
||||||
self.assertEqual(self._count, 200)
|
self.assertEqual(self._count, 200)
|
||||||
|
|
||||||
|
def testDisconnectCleanup(self):
|
||||||
|
for c in range(5):
|
||||||
|
self._count = 0
|
||||||
|
self._senders = []
|
||||||
|
for i in range(200):
|
||||||
|
o = QObject()
|
||||||
|
QObject.connect(o, SIGNAL("fire()"), lambda: self.myCB())
|
||||||
|
self._senders.append(o)
|
||||||
|
o.emit(SIGNAL("fire()"))
|
||||||
|
|
||||||
|
self.assertEqual(self._count, 200)
|
||||||
|
|
||||||
|
#delete all senders will disconnect the signals
|
||||||
|
self._senders = []
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue