Ignore:
Timestamp:
Nov 9, 2017 6:45:20 AM (6 years ago)
Author:
Piotr Rozyczko <rozyczko@…>
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)
Message:

Converted unit tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Plotting/UnitTesting/LinearFitTest.py

    r7fb471d r53c771e  
    33import numpy 
    44 
    5 from PyQt4 import QtGui 
     5from PyQt5 import QtGui, QtWidgets 
    66from unittest.mock import MagicMock 
     7 
     8from UnitTesting.TestUtils import QtSignalSpy 
    79 
    810# set up import paths 
     
    1517from sas.qtgui.Plotting.LinearFit import LinearFit 
    1618 
    17 if not QtGui.QApplication.instance(): 
    18     app = QtGui.QApplication(sys.argv) 
     19if not QtWidgets.QApplication.instance(): 
     20    app = QtWidgets.QApplication(sys.argv) 
    1921 
    2022class LinearFitTest(unittest.TestCase): 
     
    3638    def testDefaults(self): 
    3739        '''Test the GUI in its default state''' 
    38         self.assertIsInstance(self.widget, QtGui.QDialog) 
     40        self.assertIsInstance(self.widget, QtWidgets.QDialog) 
    3941        self.assertEqual(self.widget.windowTitle(), "Linear Fit") 
    4042        self.assertEqual(self.widget.txtA.text(), "1") 
     
    4850        '''Test the fitting wrapper ''' 
    4951        # 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) 
    5155 
    5256        # Set some initial values 
     
    5761        # Run the fitting 
    5862        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] 
    6068        # Compare 
    6169        self.assertCountEqual(return_values[0], [1.0, 3.0]) 
     
    6674        self.widget.x_is_log = True 
    6775        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] 
    6978        # Compare 
    7079        self.assertCountEqual(return_values[0], [1.0, 3.0]) 
Note: See TracChangeset for help on using the changeset viewer.