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

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 aa6028c 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
RevLine 
[488c49d]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'''
[5032ea68]20        test_string = 'my precious'
[488c49d]21
[5032ea68]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
[488c49d]30        widget = QWidget()
[5032ea68]31        spy = QtSignalSpy(widget, communicator.statusBarUpdateSignal)
[488c49d]32
33        # Emit a signal
[5032ea68]34        communicator.statusBarUpdateSignal.emit(test_string)
[488c49d]35
[5032ea68]36        # Was the signal caught by the signal spy?
37        self.assertEqual(spy.count(), 1)
[488c49d]38
39if __name__ == "__main__":
40    unittest.main()
Note: See TracBrowser for help on using the repository browser.