Changeset 3e8dee3 in sasview for src/sas/qtgui/Utilities
- Timestamp:
- Nov 8, 2017 9:22:45 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:
- 0e80658
- Parents:
- 412e069e
- Location:
- src/sas/qtgui/Utilities
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Utilities/GuiUtils.py
r412e069e r3e8dee3 528 528 with open(path,'w') as out: 529 529 has_errors = True 530 if data.dy is None or data.dy == []:530 if data.dy is None or not data.dy: 531 531 has_errors = False 532 532 # Sanity check … … 538 538 has_errors = False 539 539 if has_errors: 540 if data.dx is not None and data.dx != []:540 if data.dx is not None and data.dx: 541 541 out.write("<X> <Y> <dY> <dX>\n") 542 542 else: … … 547 547 for i in range(len(data.x)): 548 548 if has_errors: 549 if data.dx is not None and data.dx != []:549 if data.dx is not None and data.dx: 550 550 if data.dx[i] is not None: 551 551 out.write("%g %g %g %g\n" % (data.x[i], -
src/sas/qtgui/Utilities/UnitTesting/GuiUtilsTest.py
r99ea1b0 r3e8dee3 3 3 import webbrowser 4 4 5 from PyQt 4import QtCore6 from PyQt 4 import QtGui5 from PyQt5 import QtCore 6 from PyQt5 import QtGui, QtWidgets 7 7 from unittest.mock import MagicMock 8 8 … … 19 19 from sas.qtgui.Utilities.GuiUtils import * 20 20 21 if not Qt Gui.QApplication.instance():22 app = Qt Gui.QApplication(sys.argv)21 if not QtWidgets.QApplication.instance(): 22 app = QtWidgets.QApplication(sys.argv) 23 23 24 24 class GuiUtilsTest(unittest.TestCase): … … 90 90 # Make sure test_item got all data added 91 91 self.assertEqual(test_item.child(0).text(), name) 92 list_from_item = test_item.child(0).data() .toList()92 list_from_item = test_item.child(0).data() 93 93 self.assertIsInstance(list_from_item, list) 94 self.assertEqual(list_from_item[0] .toPyObject(), test_list[0])95 self.assertEqual(list_from_item[1] .toPyObject(), test_list[1])96 self.assertEqual(list_from_item[2] .toPyObject(), test_list[2])94 self.assertEqual(list_from_item[0], test_list[0]) 95 self.assertEqual(list_from_item[1], test_list[1]) 96 self.assertEqual(list_from_item[2], test_list[2]) 97 97 98 98 def testupdateModelItemWithPlot(self): … … 111 111 self.assertEqual(test_item.child(0).text(), name) 112 112 self.assertTrue(test_item.child(0).isCheckable()) 113 list_from_item = test_item.child(0).child(0).data() .toPyObject()113 list_from_item = test_item.child(0).child(0).data() 114 114 self.assertIsInstance(list_from_item, list) 115 115 self.assertEqual(str(list_from_item[0]), test_list[0]) … … 305 305 # Test the .txt format 306 306 file_name = "test123_out.txt" 307 Qt Gui.QFileDialog.getSaveFileName = MagicMock(return_value=file_name)307 QtWidgets.QFileDialog.getSaveFileName = MagicMock(return_value=(file_name,'')) 308 308 data.filename = "test123.txt" 309 309 saveData1D(data) … … 313 313 # Test the .xml format 314 314 file_name = "test123_out.xml" 315 Qt Gui.QFileDialog.getSaveFileName = MagicMock(return_value=file_name)315 QtWidgets.QFileDialog.getSaveFileName = MagicMock(return_value=(file_name,'')) 316 316 data.filename = "test123.xml" 317 317 saveData1D(data) … … 321 321 # Test the wrong format 322 322 file_name = "test123_out.mp3" 323 Qt Gui.QFileDialog.getSaveFileName = MagicMock(return_value=file_name)323 QtWidgets.QFileDialog.getSaveFileName = MagicMock(return_value=(file_name,'')) 324 324 data.filename = "test123.mp3" 325 325 saveData1D(data) … … 337 337 # Test the .txt format 338 338 file_name = "test123_out.dat" 339 Qt Gui.QFileDialog.getSaveFileName = MagicMock(return_value=file_name)339 QtWidgets.QFileDialog.getSaveFileName = MagicMock(return_value=(file_name,'')) 340 340 data.filename = "test123.dat" 341 341 saveData2D(data) … … 345 345 # Test the wrong format 346 346 file_name = "test123_out.mp3" 347 Qt Gui.QFileDialog.getSaveFileName = MagicMock(return_value=file_name)347 QtWidgets.QFileDialog.getSaveFileName = MagicMock(return_value=(file_name,'')) 348 348 data.filename = "test123.mp3" 349 349 saveData2D(data) -
src/sas/qtgui/Utilities/UnitTesting/SasviewLoggerTest.py
r464cd07 r3e8dee3 3 3 import logging 4 4 5 from PyQt4.QtGui import * 6 from PyQt4.QtCore import * 5 from PyQt5.QtGui import * 6 from PyQt5.QtCore import * 7 from PyQt5.QtWidgets import * 7 8 8 9 # set up import paths
Note: See TracChangeset
for help on using the changeset viewer.