ESS_GUIESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalc
Last change
on this file since 18f11a6 was
53c771e,
checked in by Piotr Rozyczko <rozyczko@…>, 7 years ago
|
Converted unit tests
|
-
Property mode set to
100644
|
File size:
1.4 KB
|
Rev | Line | |
---|
[27313b7] | 1 | import sys |
---|
| 2 | import unittest |
---|
| 3 | |
---|
[53c771e] | 4 | from PyQt5 import QtGui, QtWidgets |
---|
[27313b7] | 5 | |
---|
| 6 | # set up import paths |
---|
[83eb5208] | 7 | import sas.qtgui.path_prepare |
---|
[27313b7] | 8 | |
---|
| 9 | # Local |
---|
[83eb5208] | 10 | from sas.qtgui.Plotting.WindowTitle import WindowTitle |
---|
[27313b7] | 11 | |
---|
[53c771e] | 12 | if not QtWidgets.QApplication.instance(): |
---|
| 13 | app = QtWidgets.QApplication(sys.argv) |
---|
[27313b7] | 14 | |
---|
| 15 | class WindowTitleTest(unittest.TestCase): |
---|
| 16 | '''Test the WindowTitle''' |
---|
| 17 | def setUp(self): |
---|
| 18 | '''Create the WindowTitle''' |
---|
| 19 | self.widget = WindowTitle(None, new_title="some title") |
---|
| 20 | |
---|
| 21 | def tearDown(self): |
---|
| 22 | '''Destroy the GUI''' |
---|
| 23 | self.widget.close() |
---|
| 24 | self.widget = None |
---|
| 25 | |
---|
| 26 | def testDefaults(self): |
---|
| 27 | '''Test the GUI in its default state''' |
---|
| 28 | self.widget.show() |
---|
[53c771e] | 29 | self.assertIsInstance(self.widget, QtWidgets.QDialog) |
---|
[27313b7] | 30 | self.assertEqual(self.widget.windowTitle(), "Modify Window Title") |
---|
| 31 | |
---|
| 32 | def testTitle(self): |
---|
| 33 | '''Modify the title''' |
---|
| 34 | self.widget.show() |
---|
[53c771e] | 35 | QtWidgets.qApp.processEvents() |
---|
[27313b7] | 36 | # make sure we have the pre-set title |
---|
| 37 | self.assertEqual(self.widget.txtTitle.text(), "some title") |
---|
| 38 | # Clear the control and set it to something else |
---|
| 39 | self.widget.txtTitle.clear() |
---|
| 40 | self.widget.txtTitle.setText("5 elephants") |
---|
[53c771e] | 41 | QtWidgets.qApp.processEvents() |
---|
[27313b7] | 42 | # Retrieve value |
---|
| 43 | new_title = self.widget.title() |
---|
| 44 | # Check |
---|
| 45 | self.assertEqual(new_title, "5 elephants") |
---|
| 46 | |
---|
| 47 | if __name__ == "__main__": |
---|
| 48 | unittest.main() |
---|
Note: See
TracBrowser
for help on using the repository browser.