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

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 99ea1b0 was 99ea1b0, checked in by Piotr Rozyczko <rozyczko@…>, 7 years ago

Update for unit tests and minor functionality quirks

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