Changeset 464cd07 in sasview for src


Ignore:
Timestamp:
Aug 22, 2017 5:59:29 AM (7 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:
b2a5042
Parents:
457d961
Message:

Use singleton QApplication in unit tests to avoid issues on Ubuntu. SASVIEW-485

Location:
src/sas/qtgui
Files:
33 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Calculators/GenericScatteringCalculator.py

    • Property mode changed from 100755 to 100644
    r457d961 r464cd07  
    100100 
    101101        # plots - 3D in real space 
    102         self.trigger_plot_3d.connect(lambda: self.plot3d(has_arrow=False)) 
     102        plot3d = self.plot3d(has_arrow=False) 
     103        self.trigger_plot_3d.connect(plot3d) 
     104        #self.trigger_plot_3d.connect(lambda: self.plot3d(has_arrow=False)) 
    103105 
    104106        self.graph_num = 1  # index for name of graph 
  • src/sas/qtgui/Calculators/UnitTesting/DensityCalculatorTest.py

    r83eb5208 r464cd07  
    1919import sas.qtgui.Utilities.LocalConfig 
    2020 
    21 app = QtGui.QApplication(sys.argv) 
     21if not QtGui.QApplication.instance(): 
     22    app = QtGui.QApplication(sys.argv) 
    2223 
    2324class ToMolarMassTest(unittest.TestCase): 
  • src/sas/qtgui/Calculators/UnitTesting/GenericScatteringCalculatorTest.py

    • Property mode changed from 100755 to 100644
    r457d961 r464cd07  
    2424from sas.sascalc.calculator import sas_gen 
    2525 
    26 app = QtGui.QApplication(sys.argv) 
     26if not QtGui.QApplication.instance(): 
     27    app = QtGui.QApplication(sys.argv) 
    2728 
    2829 
  • src/sas/qtgui/Calculators/UnitTesting/KiessigCalculatorTest.py

    r83eb5208 r464cd07  
    1111from sas.qtgui.Calculators.KiessigPanel import KiessigPanel 
    1212 
    13 app = QtGui.QApplication(sys.argv) 
     13if not QtGui.QApplication.instance(): 
     14    app = QtGui.QApplication(sys.argv) 
    1415 
    1516 
  • src/sas/qtgui/Calculators/UnitTesting/SLDCalculatorTest.py

    r83eb5208 r464cd07  
    2020import sas.qtgui.Utilities.LocalConfig 
    2121 
    22 app = QtGui.QApplication(sys.argv) 
     22if not QtGui.QApplication.instance(): 
     23    app = QtGui.QApplication(sys.argv) 
    2324 
    2425class SldResultTest(unittest.TestCase): 
  • src/sas/qtgui/Calculators/UnitTesting/SlitSizeCalculatorTest.py

    r83eb5208 r464cd07  
    1212from sas.sascalc.dataloader.loader import Loader 
    1313 
    14 app = QtGui.QApplication(sys.argv) 
     14if not QtGui.QApplication.instance(): 
     15    app = QtGui.QApplication(sys.argv) 
    1516 
    1617 
     
    8788                                self.widget.calculateSlitSize, data) 
    8889 
    89         filename = "empty_file.txt" 
    90         loader = Loader() 
    91         data = loader.load(filename) 
    92         self.assertRaisesRegexp(RuntimeError, 
    93                                 "ERROR: Data hasn't been loaded correctly", 
    94                                 self.widget.calculateSlitSize, data) 
    95  
    9690        data = None 
    9791        self.assertRaisesRegexp(RuntimeError, 
  • src/sas/qtgui/GUITests.py

    r72f4834 r464cd07  
    11import unittest 
     2import sys 
     3from PyQt4 import QtGui 
     4 
     5# Prepare the general QApplication instance 
     6app = QtGui.QApplication(sys.argv) 
    27 
    38# Main Window 
     
    3035from Calculators.UnitTesting import DensityCalculatorTest 
    3136from Calculators.UnitTesting import GenericScatteringCalculatorTest 
     37from Calculators.UnitTesting import SLDCalculatorTest 
     38from Calculators.UnitTesting import SlitSizeCalculatorTest 
    3239 
    3340# Utilities 
     
    4653from Perspectives.Fitting.UnitTesting import FitPageTest 
    4754from Perspectives.Fitting.UnitTesting import FittingOptionsTest 
    48  
    4955 
    5056def suite(): 
     
    8490        unittest.makeSuite(DensityCalculatorTest.DensityCalculatorTest,                     'test'), 
    8591        unittest.makeSuite(GenericScatteringCalculatorTest.GenericScatteringCalculatorTest, 'test'), 
     92        unittest.makeSuite(SLDCalculatorTest.SLDCalculatorTest, 'test'), 
     93        unittest.makeSuite(SlitSizeCalculatorTest.SlitSizeCalculatorTest, 'test'), 
    8694 
    8795        # Perspectives 
  • src/sas/qtgui/MainWindow/UnitTesting/AboutBoxTest.py

    r83eb5208 r464cd07  
    33import webbrowser 
    44 
    5 from PyQt4.QtGui import * 
     5from PyQt4 import QtGui 
    66from PyQt4.QtTest import QTest 
    7 from PyQt4.QtCore import * 
     7from PyQt4 import QtCore 
    88from mock import MagicMock 
    99 
     
    1515import sas.qtgui.Utilities.LocalConfig as LocalConfig 
    1616 
    17 app = QApplication(sys.argv) 
     17if not QtGui.QApplication.instance(): 
     18    app = QtGui.QApplication(sys.argv) 
    1819 
    1920class AboutBoxTest(unittest.TestCase): 
     
    3031    def testDefaults(self): 
    3132        '''Test the GUI in its default state''' 
    32         self.assertIsInstance(self.widget, QWidget) 
     33        self.assertIsInstance(self.widget, QtGui.QWidget) 
    3334        self.assertEqual(self.widget.windowTitle(), "About") 
    3435        self.assertEqual(self.widget.cmdOK.text(), "OK") 
     
    4445        """ 
    4546        version = self.widget.lblVersion 
    46         self.assertIsInstance(version, QLabel) 
     47        self.assertIsInstance(version, QtGui.QLabel) 
    4748        self.assertEqual(str(version.text()), str(LocalConfig.__version__)) 
    4849 
     
    5253        """ 
    5354        about = self.widget.lblAbout 
    54         self.assertIsInstance(about, QLabel) 
     55        self.assertIsInstance(about, QtGui.QLabel) 
    5556        # build version 
    5657        self.assertIn(str(LocalConfig.__build__), about.text()) 
     
    8283 
    8384        # Press the buttons 
    84         buttonList = self.widget.findChildren(QPushButton) 
     85        buttonList = self.widget.findChildren(QtGui.QPushButton) 
    8586        for button in buttonList: 
    86             QTest.mouseClick(button, Qt.LeftButton) 
     87            QTest.mouseClick(button, QtCore.Qt.LeftButton) 
    8788            #open_link = webbrowser.open.call_args 
    8889            args, _ = webbrowser.open.call_args 
     
    9697        self.assertTrue(self.widget.isVisible()) 
    9798        # Click on the OK button 
    98         QTest.mouseClick(self.widget.cmdOK, Qt.LeftButton) 
     99        QTest.mouseClick(self.widget.cmdOK, QtCore.Qt.LeftButton) 
    99100        # assure the widget is no longer seen 
    100101        self.assertFalse(self.widget.isVisible()) 
  • src/sas/qtgui/MainWindow/UnitTesting/DataExplorerTest.py

    rdc5ef15 r464cd07  
    2525import sas.qtgui.Plotting.PlotHelper as PlotHelper 
    2626 
    27 app = QApplication(sys.argv) 
     27if not QApplication.instance(): 
     28    app = QApplication(sys.argv) 
    2829 
    2930class DataExplorerTest(unittest.TestCase): 
     
    441442        # Click on the Help button 
    442443        QTest.mouseClick(button1, Qt.LeftButton) 
    443         qApp.processEvents() 
     444        QtGui.qApp.processEvents() 
    444445 
    445446        # Check the browser 
     
    450451        # Click on the Help_2 button 
    451452        QTest.mouseClick(button2, Qt.LeftButton) 
    452         qApp.processEvents() 
     453        QtGui.qApp.processEvents() 
    453454        # Check the browser 
    454455        self.assertIn(partial_url, str(self.form._helpView.url())) 
  • src/sas/qtgui/MainWindow/UnitTesting/DroppableDataLoadWidgetTest.py

    r83eb5208 r464cd07  
    1313from sas.qtgui.UnitTesting.TestUtils import QtSignalSpy 
    1414 
    15 app = QApplication(sys.argv) 
     15if not QApplication.instance(): 
     16    app = QApplication(sys.argv) 
    1617 
    1718class DroppableDataLoadWidgetTest(unittest.TestCase): 
  • src/sas/qtgui/MainWindow/UnitTesting/GuiManagerTest.py

    r83eb5208 r464cd07  
    2424from sas.qtgui.UnitTesting.TestUtils import QtSignalSpy 
    2525 
    26 app = QApplication(sys.argv) 
     26if not QApplication.instance(): 
     27    app = QApplication(sys.argv) 
    2728 
    2829class GuiManagerTest(unittest.TestCase): 
  • src/sas/qtgui/MainWindow/UnitTesting/MainWindowTest.py

    r83eb5208 r464cd07  
    1414from sas.qtgui.MainWindow.MainWindow import SplashScreen 
    1515 
    16 app = QtGui.QApplication(sys.argv) 
     16if not QtGui.QApplication.instance(): 
     17    app = QtGui.QApplication(sys.argv) 
    1718 
    1819class MainWindowTest(unittest.TestCase): 
  • src/sas/qtgui/MainWindow/UnitTesting/WelcomePanelTest.py

    r83eb5208 r464cd07  
    1010from sas.qtgui.MainWindow.WelcomePanel import WelcomePanel 
    1111 
    12 app = QtGui.QApplication(sys.argv) 
     12if not QtGui.QApplication.instance(): 
     13    app = QtGui.QApplication(sys.argv) 
    1314 
    1415class WelcomePanelTest(unittest.TestCase): 
  • src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingLogicTest.py

    • Property mode changed from 100755 to 100644
    rdc5ef15 r464cd07  
    1313from sas.qtgui.Plotting.PlotterData import Data1D 
    1414 
    15 app = QtGui.QApplication(sys.argv) 
     15if not QtGui.QApplication.instance(): 
     16    app = QtGui.QApplication(sys.argv) 
    1617 
    1718 
  • src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingOptionsTest.py

    r377ade1 r464cd07  
    1616from sas.qtgui.Perspectives.Fitting.FittingOptions import FittingOptions 
    1717 
    18 app = QtGui.QApplication(sys.argv) 
     18if not QtGui.QApplication.instance(): 
     19    app = QtGui.QApplication(sys.argv) 
    1920 
    2021class FittingOptionsTest(unittest.TestCase): 
  • src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingPerspectiveTest.py

    r0e4d87c r464cd07  
    1616from sas.qtgui.Perspectives.Fitting.FittingPerspective import FittingWindow 
    1717 
    18 app = QtGui.QApplication(sys.argv) 
     18if not QtGui.QApplication.instance(): 
     19    app = QtGui.QApplication(sys.argv) 
    1920 
    2021class FittingPerspectiveTest(unittest.TestCase): 
  • src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingWidgetTest.py

    r377ade1 r464cd07  
    2020from sas.qtgui.Plotting.PlotterData import Data2D 
    2121 
    22 app = QtGui.QApplication(sys.argv) 
     22if not QtGui.QApplication.instance(): 
     23    app = QtGui.QApplication(sys.argv) 
    2324 
    2425class dummy_manager(object): 
  • src/sas/qtgui/Plotting/UnitTesting/AddTextTest.py

    r83eb5208 r464cd07  
    1111from sas.qtgui.Plotting.AddText import AddText 
    1212 
    13 app = QtGui.QApplication(sys.argv) 
     13if not QtGui.QApplication.instance(): 
     14    app = QtGui.QApplication(sys.argv) 
    1415 
    1516class AddTextTest(unittest.TestCase): 
  • src/sas/qtgui/Plotting/UnitTesting/BoxSumTest.py

    r83eb5208 r464cd07  
    1212from sas.qtgui.Plotting.BoxSum import BoxSum 
    1313 
    14 app = QtGui.QApplication(sys.argv) 
     14if not QtGui.QApplication.instance(): 
     15    app = QtGui.QApplication(sys.argv) 
    1516 
    1617class BoxSumTest(unittest.TestCase): 
  • src/sas/qtgui/Plotting/UnitTesting/ColorMapTest.py

    rdc5ef15 r464cd07  
    1818from sas.qtgui.Plotting.ColorMap import ColorMap 
    1919 
    20 app = QtGui.QApplication(sys.argv) 
     20if not QtGui.QApplication.instance(): 
     21    app = QtGui.QApplication(sys.argv) 
    2122 
    2223class ColorMapTest(unittest.TestCase): 
  • src/sas/qtgui/Plotting/UnitTesting/LinearFitTest.py

    rdc5ef15 r464cd07  
    1515from sas.qtgui.Plotting.LinearFit import LinearFit 
    1616 
    17 app = QtGui.QApplication(sys.argv) 
     17if not QtGui.QApplication.instance(): 
     18    app = QtGui.QApplication(sys.argv) 
    1819 
    1920class LinearFitTest(unittest.TestCase): 
  • src/sas/qtgui/Plotting/UnitTesting/PlotPropertiesTest.py

    r83eb5208 r464cd07  
    1111from sas.qtgui.Plotting.PlotProperties import PlotProperties 
    1212 
    13 app = QtGui.QApplication(sys.argv) 
     13if not QtGui.QApplication.instance(): 
     14    app = QtGui.QApplication(sys.argv) 
    1415 
    1516class PlotPropertiesTest(unittest.TestCase): 
  • src/sas/qtgui/Plotting/UnitTesting/Plotter2DTest.py

    rdc5ef15 r464cd07  
    1919import sas.qtgui.Plotting.Plotter2D as Plotter2D 
    2020 
    21 app = QtGui.QApplication(sys.argv) 
     21if not QtGui.QApplication.instance(): 
     22    app = QtGui.QApplication(sys.argv) 
    2223 
    2324class Plotter2DTest(unittest.TestCase): 
     
    159160        def done(): 
    160161            self.clipboard_called = True 
    161         QtCore.QObject.connect(app.clipboard(), QtCore.SIGNAL("dataChanged()"), done) 
     162        QtCore.QObject.connect(QtGui.qApp.clipboard(), QtCore.SIGNAL("dataChanged()"), done) 
    162163        actions[2].trigger() 
    163164        QtGui.qApp.processEvents() 
  • src/sas/qtgui/Plotting/UnitTesting/PlotterBaseTest.py

    rdc5ef15 r464cd07  
    2020import sas.qtgui.Plotting.PlotterBase as PlotterBase 
    2121 
    22 app = QtGui.QApplication(sys.argv) 
     22if not QtGui.QApplication.instance(): 
     23    app = QtGui.QApplication(sys.argv) 
    2324 
    2425class PlotterBaseTest(unittest.TestCase): 
     
    149150        def done(): 
    150151            self.clipboard_called = True 
    151         QtCore.QObject.connect(app.clipboard(), QtCore.SIGNAL("dataChanged()"), done) 
     152        QtCore.QObject.connect(QtGui.qApp.clipboard(), QtCore.SIGNAL("dataChanged()"), done) 
    152153        actions[2].trigger() 
    153154        QtGui.qApp.processEvents() 
  • src/sas/qtgui/Plotting/UnitTesting/PlotterTest.py

    rdc5ef15 r464cd07  
    2020import sas.qtgui.Plotting.Plotter as Plotter 
    2121 
    22 app = QtGui.QApplication(sys.argv) 
     22if not QtGui.QApplication.instance(): 
     23    app = QtGui.QApplication(sys.argv) 
    2324 
    2425 
     
    9798        def done(): 
    9899            self.clipboard_called = True 
    99         QtCore.QObject.connect(app.clipboard(), QtCore.SIGNAL("dataChanged()"), done) 
     100        QtCore.QObject.connect(QtGui.qApp.clipboard(), QtCore.SIGNAL("dataChanged()"), done) 
    100101        actions[2].trigger() 
    101102        QtGui.qApp.processEvents() 
  • src/sas/qtgui/Plotting/UnitTesting/ScalePropertiesTest.py

    r83eb5208 r464cd07  
    1010from sas.qtgui.Plotting.ScaleProperties import ScaleProperties 
    1111 
    12 app = QtGui.QApplication(sys.argv) 
     12if not QtGui.QApplication.instance(): 
     13    app = QtGui.QApplication(sys.argv) 
    1314 
    1415class ScalePropertiesTest(unittest.TestCase): 
  • src/sas/qtgui/Plotting/UnitTesting/SetGraphRangeTest.py

    r83eb5208 r464cd07  
    1010from sas.qtgui.Plotting.SetGraphRange import SetGraphRange 
    1111 
    12 app = QtGui.QApplication(sys.argv) 
     12if not QtGui.QApplication.instance(): 
     13    app = QtGui.QApplication(sys.argv) 
    1314 
    1415class SetGraphRangeTest(unittest.TestCase): 
  • src/sas/qtgui/Plotting/UnitTesting/SlicerModelTest.py

    r83eb5208 r464cd07  
    1212from sas.qtgui.Plotting.SlicerModel import SlicerModel 
    1313 
    14 app = QtGui.QApplication(sys.argv) 
     14if not QtGui.QApplication.instance(): 
     15    app = QtGui.QApplication(sys.argv) 
    1516 
    1617class SlicerModelTest(unittest.TestCase): 
  • src/sas/qtgui/Plotting/UnitTesting/SlicerParametersTest.py

    • Property mode changed from 100755 to 100644
    r83eb5208 r464cd07  
    1818from sas.qtgui.Plotting.SlicerParameters import SlicerParameters 
    1919 
    20 app = QtGui.QApplication(sys.argv) 
     20if not QtGui.QApplication.instance(): 
     21    app = QtGui.QApplication(sys.argv) 
    2122 
    2223class SlicerParametersTest(unittest.TestCase): 
  • src/sas/qtgui/Plotting/UnitTesting/WindowTitleTest.py

    r83eb5208 r464cd07  
    1010from sas.qtgui.Plotting.WindowTitle import WindowTitle 
    1111 
    12 app = QtGui.QApplication(sys.argv) 
     12if not QtGui.QApplication.instance(): 
     13    app = QtGui.QApplication(sys.argv) 
    1314 
    1415class WindowTitleTest(unittest.TestCase): 
     
    3233        '''Modify the title''' 
    3334        self.widget.show() 
    34         app.processEvents() 
     35        QtGui.qApp.processEvents() 
    3536        # make sure we have the pre-set title 
    3637        self.assertEqual(self.widget.txtTitle.text(), "some title") 
     
    3839        self.widget.txtTitle.clear() 
    3940        self.widget.txtTitle.setText("5 elephants") 
    40         app.processEvents() 
     41        QtGui.qApp.processEvents() 
    4142        # Retrieve value 
    4243        new_title = self.widget.title() 
  • src/sas/qtgui/UnitTesting/TestUtilsTest.py

    r83eb5208 r464cd07  
    1111from sas.qtgui.UnitTesting.TestUtils import * 
    1212 
    13 app = QApplication(sys.argv) 
     13if not QApplication.instance(): 
     14    app = QApplication(sys.argv) 
    1415 
    1516class TestUtilsTest(unittest.TestCase): 
  • src/sas/qtgui/Utilities/UnitTesting/GuiUtilsTest.py

    rdc5ef15 r464cd07  
    1919from sas.qtgui.Utilities.GuiUtils import * 
    2020 
    21 app = QtGui.QApplication(sys.argv) 
     21if not QtGui.QApplication.instance(): 
     22    app = QtGui.QApplication(sys.argv) 
    2223 
    2324class GuiUtilsTest(unittest.TestCase): 
  • src/sas/qtgui/Utilities/UnitTesting/SasviewLoggerTest.py

    r83eb5208 r464cd07  
    1313from sas.qtgui.Utilities.SasviewLogger import QtHandler 
    1414 
    15 app = QApplication(sys.argv) 
     15if not QApplication.instance(): 
     16    app = QApplication(sys.argv) 
    1617 
    1718class SasviewLoggerTest(unittest.TestCase): 
Note: See TracChangeset for help on using the changeset viewer.