summaryrefslogtreecommitdiffstats
path: root/tests/QtCore/bug_PYSIDE-164.py
blob: 53a1bd6c220930f6f84a06993e53a8fb426cc496 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from PySide.QtCore import QCoreApplication, QEventLoop, QObject, Qt, QThread, QTimer, SIGNAL
import unittest


class Emitter(QThread):
    def __init__(self):
        QThread.__init__(self)

    def run(self):
        print "Before emit."
        self.emit(SIGNAL("signal(int)"), 0)
        print "After emit."

class Receiver(QObject):
    def __init__(self, eventloop):
        QObject.__init__(self)
        self.eventloop = eventloop

    def receive(self, number):
        print "Received number: %d" % number
        self.eventloop.exit(0)


class TestBugPYSIDE164(unittest.TestCase):

    def testBlockingSignal(self):
        app = QCoreApplication.instance() or QCoreApplication([])
        eventloop = QEventLoop()
        emitter = Emitter()
        receiver = Receiver(eventloop)
        emitter.connect(emitter, SIGNAL("signal(int)"),
                        receiver.receive, Qt.BlockingQueuedConnection)
        emitter.start()
        retval = eventloop.exec_()
        emitter.wait()
        self.assertEqual(retval, 0)

if __name__ == '__main__':
    unittest.main()