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 9f25bce was
5032ea68,
checked in by Piotr Rozyczko <piotr.rozyczko@…>, 9 years ago
|
threaded file load, data object related fixes, more unit tests.
|
-
Property mode set to
100755
|
File size:
1.0 KB
|
Rev | Line | |
---|
[488c49d] | 1 | import sys |
---|
| 2 | import unittest |
---|
| 3 | |
---|
| 4 | from PyQt4.QtGui import * |
---|
| 5 | from PyQt4.QtTest import QTest |
---|
| 6 | from PyQt4.QtCore import * |
---|
| 7 | from mock import MagicMock |
---|
| 8 | |
---|
| 9 | # Local |
---|
| 10 | from GuiUtils import Communicate |
---|
| 11 | from UnitTesting.TestUtils import * |
---|
| 12 | |
---|
| 13 | app = QApplication(sys.argv) |
---|
| 14 | |
---|
| 15 | class 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 | |
---|
| 39 | if __name__ == "__main__": |
---|
| 40 | unittest.main() |
---|
Note: See
TracBrowser
for help on using the repository browser.