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 a3221b6 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 | |
---|
1 | import sys |
---|
2 | import unittest |
---|
3 | |
---|
4 | from PyQt5.QtGui import * |
---|
5 | from PyQt5.QtWidgets import * |
---|
6 | from PyQt5.QtTest import QTest |
---|
7 | from PyQt5.QtCore import * |
---|
8 | from unittest.mock import MagicMock |
---|
9 | |
---|
10 | # Local |
---|
11 | from sas.qtgui.Utilities.GuiUtils import Communicate |
---|
12 | from sas.qtgui.UnitTesting.TestUtils import * |
---|
13 | |
---|
14 | if not QApplication.instance(): |
---|
15 | app = QApplication(sys.argv) |
---|
16 | |
---|
17 | class 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 | |
---|
41 | if __name__ == "__main__": |
---|
42 | unittest.main() |
---|
Note: See
TracBrowser
for help on using the repository browser.