Changeset 53c771e in sasview for src/sas/qtgui/Plotting/UnitTesting/Plotter2DTest.py
- Timestamp:
- Nov 9, 2017 8:45:20 AM (7 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 09:22:45)
- git-committer:
- Piotr Rozyczko <rozyczko@…> (11/09/17 08:45:20)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Plotting/UnitTesting/Plotter2DTest.py
r7fb471d r53c771e 4 4 import platform 5 5 6 from PyQt 4 import QtGui7 from PyQt 4import QtCore8 from matplotlib.backends.backend_qt 4agg import FigureCanvasQTAgg as FigureCanvas6 from PyQt5 import QtGui, QtWidgets, QtPrintSupport 7 from PyQt5 import QtCore 8 from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas 9 9 from unittest.mock import MagicMock 10 10 from mpl_toolkits.mplot3d import Axes3D … … 20 20 import sas.qtgui.Plotting.Plotter2D as Plotter2D 21 21 22 if not Qt Gui.QApplication.instance():23 app = Qt Gui.QApplication(sys.argv)22 if not QtWidgets.QApplication.instance(): 23 app = QtWidgets.QApplication(sys.argv) 24 24 25 25 class Plotter2DTest(unittest.TestCase): … … 53 53 def tearDown(self): 54 54 '''destroy''' 55 self.plotter.figure.clf() 55 56 self.plotter = None 56 57 … … 73 74 74 75 self.assertTrue(FigureCanvas.draw_idle.called) 76 self.plotter.figure.clf() 75 77 76 78 def testCalculateDepth(self): … … 94 96 self.plotter.show() 95 97 96 Qt Gui.QDialog.exec_ = MagicMock(return_value=QtGui.QDialog.Accepted)98 QtWidgets.QDialog.exec_ = MagicMock(return_value=QtWidgets.QDialog.Accepted) 97 99 98 100 # Just this one plot … … 100 102 101 103 # Check that exec_ got called 102 self.assertTrue(Qt Gui.QDialog.exec_.called)104 self.assertTrue(QtWidgets.QDialog.exec_.called) 103 105 104 106 self.assertEqual(self.plotter.cmap, "jet") 105 107 self.assertAlmostEqual(self.plotter.vmin, 0.1, 6) 106 108 self.assertAlmostEqual(self.plotter.vmax, 1e+20, 6) 109 self.plotter.figure.clf() 107 110 108 111 def testOnToggleScale(self): … … 115 118 116 119 self.assertTrue(FigureCanvas.draw_idle.called) 120 self.plotter.figure.clf() 117 121 118 122 def testOnBoxSum(self): … … 135 139 self.assertTrue(self.plotter.boxwidget.isVisible()) 136 140 self.assertIsInstance(self.plotter.boxwidget.model, QtGui.QStandardItemModel) 141 self.plotter.figure.clf() 137 142 138 143 def testContextMenuQuickPlot(self): … … 151 156 # Trigger Print Image and make sure the method is called 152 157 self.assertEqual(actions[1].text(), "Print Image") 153 Qt Gui.QPrintDialog.exec_ = MagicMock(return_value=QtGui.QDialog.Rejected)158 QtPrintSupport.QPrintDialog.exec_ = MagicMock(return_value=QtWidgets.QDialog.Rejected) 154 159 actions[1].trigger() 155 self.assertTrue(Qt Gui.QPrintDialog.exec_.called)160 self.assertTrue(QtPrintSupport.QPrintDialog.exec_.called) 156 161 157 162 # Trigger Copy to Clipboard and make sure the method is called … … 176 181 def done(): 177 182 self.clipboard_called = True 178 QtCore.QObject.connect(Qt Gui.qApp.clipboard(), QtCore.SIGNAL("dataChanged()"), done)183 QtCore.QObject.connect(QtWidgets.qApp.clipboard(), QtCore.SIGNAL("dataChanged()"), done) 179 184 actions[2].trigger() 180 Qt Gui.qApp.processEvents()185 QtWidgets.qApp.processEvents() 181 186 # Make sure clipboard got updated. 182 187 self.assertTrue(self.clipboard_called) 188 self.plotter.figure.clf() 183 189 184 190 def testShowNoPlot(self): … … 200 206 self.assertFalse(FigureCanvas.draw_idle.called) 201 207 self.assertFalse(FigureCanvas.draw.called) 208 self.plotter.figure.clf() 202 209 203 210 def testShow3DPlot(self): … … 220 227 self.assertTrue(Axes3D.plot_surface.called) 221 228 self.assertTrue(FigureCanvas.draw.called) 229 self.plotter.figure.clf() 222 230 223 231 def testShow2DPlot(self): … … 238 246 zmax=None) 239 247 self.assertTrue(FigureCanvas.draw_idle.called) 248 self.plotter.figure.clf() 240 249 241 250
Note: See TracChangeset
for help on using the changeset viewer.