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 2162fa0 was
2162fa0,
checked in by wojciech, 7 years ago
|
Unit testing for main fitting window
|
-
Property mode set to
100644
|
File size:
1.2 KB
|
Rev | Line | |
---|
[2162fa0] | 1 | import sys |
---|
| 2 | import unittest |
---|
| 3 | |
---|
| 4 | from PyQt4 import QtGui |
---|
| 5 | from PyQt4 import QtTest |
---|
| 6 | from PyQt4 import QtCore |
---|
| 7 | from mock import MagicMock |
---|
| 8 | |
---|
| 9 | # Local |
---|
| 10 | from FittingPerspective import FittingWindow |
---|
| 11 | |
---|
| 12 | app = QtGui.QApplication(sys.argv) |
---|
| 13 | |
---|
| 14 | class FittingPerspectiveTest(unittest.TestCase): |
---|
| 15 | """Test the Main Window GUI""" |
---|
| 16 | def setUp(self): |
---|
| 17 | """Create the GUI""" |
---|
| 18 | |
---|
| 19 | self.widget = FittingWindow(None) |
---|
| 20 | |
---|
| 21 | def tearDown(self): |
---|
| 22 | """Destroy the GUI""" |
---|
| 23 | self.widget = None |
---|
| 24 | |
---|
| 25 | def testDefaults(self): |
---|
| 26 | """Test the GUI in its default state""" |
---|
| 27 | self.assertIsInstance(self.widget, QtGui.QMainWindow) |
---|
| 28 | self.assertIsInstance(self.widget.centralWidget(), QtGui.QWorkspace) |
---|
| 29 | |
---|
| 30 | def testExit(self): |
---|
| 31 | """ |
---|
| 32 | Test that the custom exit method is called on shutdown |
---|
| 33 | """ |
---|
| 34 | # Must mask sys.exit, otherwise the whole testing process stops. |
---|
| 35 | sys.exit = MagicMock() |
---|
| 36 | QtGui.QMessageBox.question = MagicMock(return_value=QtGui.QMessageBox.Yes) |
---|
| 37 | |
---|
| 38 | # Open, then close the main window |
---|
| 39 | tmp_main = FittingWindow(None) |
---|
| 40 | tmp_main.close() |
---|
| 41 | |
---|
| 42 | # See that the MessageBox method got called |
---|
| 43 | self.assertTrue(QtGui.QMessageBox.question.called) |
---|
| 44 | |
---|
| 45 | if __name__ == "__main__": |
---|
| 46 | unittest.main() |
---|
Note: See
TracBrowser
for help on using the repository browser.