source: sasview/src/sas/qtgui/UnitTesting/TestUtilsTest.py @ cbcdd2c

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalc
Last change on this file since cbcdd2c was 5032ea68, checked in by Piotr Rozyczko <piotr.rozyczko@…>, 8 years ago

threaded file load, data object related fixes, more unit tests.

  • Property mode set to 100755
File size: 1.0 KB
Line 
1import sys
2import unittest
3
4from PyQt4.QtGui import *
5from PyQt4.QtTest import QTest
6from PyQt4.QtCore import *
7from mock import MagicMock
8
9# Local
10from GuiUtils import Communicate
11from UnitTesting.TestUtils import *
12
13app = QApplication(sys.argv)
14
15class TestUtilsTest(unittest.TestCase):
16    '''Test TestUtils'''
17
18    def testQtSignalSpy(self):
19        '''Create the Spy the correct way'''
20        test_string = 'my precious'
21
22        def signalReceived(signal):
23            # Test the signal callback
24            self.assertEqual(signal, test_string)
25
26        communicator = Communicate()
27        communicator.statusBarUpdateSignal.connect(signalReceived)
28
29        # Define the signal spy for testing
30        widget = QWidget()
31        spy = QtSignalSpy(widget, communicator.statusBarUpdateSignal)
32
33        # Emit a signal
34        communicator.statusBarUpdateSignal.emit(test_string)
35
36        # Was the signal caught by the signal spy?
37        self.assertEqual(spy.count(), 1)
38
39if __name__ == "__main__":
40    unittest.main()
Note: See TracBrowser for help on using the repository browser.