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

ESS_GUIESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_opencl
Last change on this file since 12dfce6 was 53c771e, checked in by Piotr Rozyczko <rozyczko@…>, 7 years ago

Converted unit tests

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