Ignore:
Timestamp:
Aug 22, 2017 3: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/MainWindow/UnitTesting
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • 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): 
Note: See TracChangeset for help on using the changeset viewer.