Changeset 53c771e in sasview for src/sas/qtgui/Plotting/UnitTesting/LinearFitTest.py
- Timestamp:
- Nov 9, 2017 6:45:20 AM (6 years ago)
- Branches:
- ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
- Children:
- dd150ef
- Parents:
- d6b8a1d
- git-author:
- Piotr Rozyczko <rozyczko@…> (11/08/17 07:22:45)
- git-committer:
- Piotr Rozyczko <rozyczko@…> (11/09/17 06:45:20)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Plotting/UnitTesting/LinearFitTest.py
r7fb471d r53c771e 3 3 import numpy 4 4 5 from PyQt 4 import QtGui5 from PyQt5 import QtGui, QtWidgets 6 6 from unittest.mock import MagicMock 7 8 from UnitTesting.TestUtils import QtSignalSpy 7 9 8 10 # set up import paths … … 15 17 from sas.qtgui.Plotting.LinearFit import LinearFit 16 18 17 if not Qt Gui.QApplication.instance():18 app = Qt Gui.QApplication(sys.argv)19 if not QtWidgets.QApplication.instance(): 20 app = QtWidgets.QApplication(sys.argv) 19 21 20 22 class LinearFitTest(unittest.TestCase): … … 36 38 def testDefaults(self): 37 39 '''Test the GUI in its default state''' 38 self.assertIsInstance(self.widget, Qt Gui.QDialog)40 self.assertIsInstance(self.widget, QtWidgets.QDialog) 39 41 self.assertEqual(self.widget.windowTitle(), "Linear Fit") 40 42 self.assertEqual(self.widget.txtA.text(), "1") … … 48 50 '''Test the fitting wrapper ''' 49 51 # Catch the update signal 50 self.widget.parent.emit = MagicMock() 52 #self.widget.updatePlot.emit = MagicMock() 53 #self.widget.updatePlot.emit = MagicMock() 54 spy_update = QtSignalSpy(self.widget, self.widget.updatePlot) 51 55 52 56 # Set some initial values … … 57 61 # Run the fitting 58 62 self.widget.fit(None) 59 return_values = self.widget.parent.emit.call_args[0][1] 63 64 # Expected one spy instance 65 self.assertEqual(spy_update.count(), 1) 66 67 return_values = spy_update.called()[0]['args'][0] 60 68 # Compare 61 69 self.assertCountEqual(return_values[0], [1.0, 3.0]) … … 66 74 self.widget.x_is_log = True 67 75 self.widget.fit(None) 68 return_values = self.widget.parent.emit.call_args[0][1] 76 self.assertEqual(spy_update.count(), 2) 77 return_values = spy_update.called()[1]['args'][0] 69 78 # Compare 70 79 self.assertCountEqual(return_values[0], [1.0, 3.0])
Note: See TracChangeset
for help on using the changeset viewer.