source: sasview/src/sas/qtgui/GUITests.py @ 144fe21

ESS_GUIESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalc
Last change on this file since 144fe21 was 144fe21, checked in by Piotr Rozyczko <rozyczko@…>, 3 years ago

new unit test runner script + test fixes. SASVIEW-970

  • Property mode set to 100644
File size: 8.9 KB
RevLine 
[06b0138]1import unittest
[464cd07]2import sys
[4992ff2]3from PyQt5 import QtGui
4from PyQt5 import QtWidgets
[464cd07]5
[32f6cdd]6"""
7Unit tests for the QT GUI
8=========================
9
10In order to run the tests, first install SasView and sasmodels to site-packages
[d0528c4]11by running ``python setup.py install`` in both repositories.
[32f6cdd]12
[144fe21]13The tests can be run with ``python GUITests.py``, or
14``python GUITests.py suiteName1 suiteName2 ...`` for a subset of tests.
15
16To get more verbose console output (recommended), use ``python GUITests.py -v``
17or modify tge VERBOSITY module variable.
[32f6cdd]18"""
19
[144fe21]20# Llist of all suite names. Every time a new suite is added, its name should
21# also be added here
22ALL_SUITES = [
23    'calculatorsSuite',
24    'mainSuite',
25    'fittingSuite',
26    'plottingSuite',
27    'utilitiesSuite',
28    'perspectivesSuite',
29    ]
30
31# Define output verbosity
32#VERBOSITY = 0 # quiet - just the total number of tests run and global result
33VERBOSITY = 1 # default - quiet + a dot for every successful test or a F for failure
34#VERBOSITY = 2 # verbose - default + help string of every test and the result
35
[464cd07]36# Prepare the general QApplication instance
[4992ff2]37app = QtWidgets.QApplication(sys.argv)
[06b0138]38
39# Main Window
40from MainWindow.UnitTesting import AboutBoxTest
41from MainWindow.UnitTesting import DataExplorerTest
42from MainWindow.UnitTesting import WelcomePanelTest
43from MainWindow.UnitTesting import DroppableDataLoadWidgetTest
44from MainWindow.UnitTesting import GuiManagerTest
45from MainWindow.UnitTesting import MainWindowTest
46
[53c771e]47## Plotting
[06b0138]48from Plotting.UnitTesting import AddTextTest
49from Plotting.UnitTesting import PlotHelperTest
50from Plotting.UnitTesting import WindowTitleTest
[53c771e]51from Plotting.UnitTesting import ScalePropertiesTest
[06b0138]52from Plotting.UnitTesting import SetGraphRangeTest
53from Plotting.UnitTesting import LinearFitTest
54from Plotting.UnitTesting import PlotPropertiesTest
55from Plotting.UnitTesting import PlotUtilitiesTest
56from Plotting.UnitTesting import ColorMapTest
57from Plotting.UnitTesting import BoxSumTest
58from Plotting.UnitTesting import SlicerModelTest
59from Plotting.UnitTesting import SlicerParametersTest
[53c771e]60from Plotting.UnitTesting import PlotterBaseTest
61from Plotting.UnitTesting import PlotterTest
62from Plotting.UnitTesting import Plotter2DTest
[06b0138]63
64# Calculators
65from Calculators.UnitTesting import KiessigCalculatorTest
66from Calculators.UnitTesting import DensityCalculatorTest
67from Calculators.UnitTesting import GenericScatteringCalculatorTest
[464cd07]68from Calculators.UnitTesting import SLDCalculatorTest
69from Calculators.UnitTesting import SlitSizeCalculatorTest
[01cda57]70from Calculators.UnitTesting import ResolutionCalculatorPanelTest
[d5c5d3d]71from Calculators.UnitTesting import DataOperationUtilityTest
[06b0138]72
73# Utilities
74from Utilities.UnitTesting import GuiUtilsTest
75from Utilities.UnitTesting import SasviewLoggerTest
[3b3b40b]76from Utilities.UnitTesting import GridPanelTest
77from Utilities.UnitTesting import ModelEditorTest
78from Utilities.UnitTesting import PluginDefinitionTest
79from Utilities.UnitTesting import TabbedModelEditorTest
[01ef3f7]80from Utilities.UnitTesting import AddMultEditorTest
[57be490]81from Utilities.UnitTesting import ReportDialogTest
[06b0138]82
83# Unit Testing
84from UnitTesting import TestUtilsTest
85
86# Perspectives
[7c487846]87#  Fitting
[06b0138]88from Perspectives.Fitting.UnitTesting import FittingWidgetTest
89from Perspectives.Fitting.UnitTesting import FittingPerspectiveTest
90from Perspectives.Fitting.UnitTesting import FittingLogicTest
91from Perspectives.Fitting.UnitTesting import FittingUtilitiesTest
92from Perspectives.Fitting.UnitTesting import FitPageTest
[72f4834]93from Perspectives.Fitting.UnitTesting import FittingOptionsTest
[0595bb7]94from Perspectives.Fitting.UnitTesting import MultiConstraintTest
[da9a0722]95from Perspectives.Fitting.UnitTesting import ComplexConstraintTest
[676f137]96from Perspectives.Fitting.UnitTesting import ConstraintWidgetTest
[0595bb7]97
[7c487846]98#  Invariant
99from Perspectives.Invariant.UnitTesting import InvariantPerspectiveTest
[06b0138]100
[676f137]101#  Inversion
102from Perspectives.Inversion.UnitTesting import InversionPerspectiveTest
103
[144fe21]104def plottingSuite():
[06b0138]105    suites = (
106        # Plotting
107        unittest.makeSuite(Plotter2DTest.Plotter2DTest,               'test'),
[53c771e]108        unittest.makeSuite(PlotHelperTest.PlotHelperTest,             'test'),
[06b0138]109        unittest.makeSuite(AddTextTest.AddTextTest,                   'test'),
[53c771e]110        unittest.makeSuite(WindowTitleTest.WindowTitleTest,           'test'),
[06b0138]111        unittest.makeSuite(ScalePropertiesTest.ScalePropertiesTest,   'test'),
112        unittest.makeSuite(SetGraphRangeTest.SetGraphRangeTest,       'test'),
113        unittest.makeSuite(LinearFitTest.LinearFitTest,               'test'),
114        unittest.makeSuite(PlotPropertiesTest.PlotPropertiesTest,     'test'),
115        unittest.makeSuite(PlotUtilitiesTest.PlotUtilitiesTest,       'test'),
116        unittest.makeSuite(ColorMapTest.ColorMapTest,                 'test'),
117        unittest.makeSuite(BoxSumTest.BoxSumTest,                     'test'),
118        unittest.makeSuite(SlicerModelTest.SlicerModelTest,           'test'),
119        unittest.makeSuite(SlicerParametersTest.SlicerParametersTest, 'test'),
[53c771e]120        unittest.makeSuite(PlotterBaseTest.PlotterBaseTest,           'test'),
121        unittest.makeSuite(PlotterTest.PlotterTest,                   'test'),
[144fe21]122        )
123    return unittest.TestSuite(suites)
[06b0138]124
[144fe21]125def mainSuite():
126    suites = (
[06b0138]127        # Main window
128        unittest.makeSuite(DataExplorerTest.DataExplorerTest,  'test'),
[f4a1433]129        unittest.makeSuite(DroppableDataLoadWidgetTest.DroppableDataLoadWidgetTest, 'test'),
[06b0138]130        unittest.makeSuite(MainWindowTest.MainWindowTest,      'test'),
[53c771e]131        unittest.makeSuite(GuiManagerTest.GuiManagerTest,      'test'),
132        unittest.makeSuite(AboutBoxTest.AboutBoxTest,          'test'),
133        unittest.makeSuite(WelcomePanelTest.WelcomePanelTest,  'test'),
[144fe21]134        )
135    return unittest.TestSuite(suites)
[06b0138]136
[144fe21]137def utilitiesSuite():
138    suites = (
139        ## Utilities
[0261bc1]140        unittest.makeSuite(TestUtilsTest.TestUtilsTest,           'test'),
141        unittest.makeSuite(SasviewLoggerTest.SasviewLoggerTest,   'test'),
142        unittest.makeSuite(GuiUtilsTest.GuiUtilsTest,             'test'),
143        unittest.makeSuite(GuiUtilsTest.DoubleValidatorTest,      'test'),
144        unittest.makeSuite(GuiUtilsTest.HashableStandardItemTest, 'test'),
[3b3b40b]145        unittest.makeSuite(GridPanelTest.BatchOutputPanelTest,    'test'),
146        unittest.makeSuite(ModelEditorTest.ModelEditorTest,            'test'),
147        unittest.makeSuite(PluginDefinitionTest.PluginDefinitionTest,  'test'),
148        unittest.makeSuite(TabbedModelEditorTest.TabbedModelEditorTest,'test'),
[01ef3f7]149        unittest.makeSuite(AddMultEditorTest.AddMultEditorTest, 'test'),
[57be490]150        unittest.makeSuite(ReportDialogTest.ReportDialogTest,     'test'),
[144fe21]151        )
152    return unittest.TestSuite(suites)
[06b0138]153
[144fe21]154def calculatorsSuite():
155    suites = (
[06b0138]156        # Calculators
157        unittest.makeSuite(KiessigCalculatorTest.KiessigCalculatorTest,                     'test'),
158        unittest.makeSuite(DensityCalculatorTest.DensityCalculatorTest,                     'test'),
159        unittest.makeSuite(GenericScatteringCalculatorTest.GenericScatteringCalculatorTest, 'test'),
[464cd07]160        unittest.makeSuite(SLDCalculatorTest.SLDCalculatorTest, 'test'),
161        unittest.makeSuite(SlitSizeCalculatorTest.SlitSizeCalculatorTest, 'test'),
[01cda57]162        unittest.makeSuite(ResolutionCalculatorPanelTest.ResolutionCalculatorPanelTest, 'test'),
[d5c5d3d]163        unittest.makeSuite(DataOperationUtilityTest.DataOperationUtilityTest, 'test'),
[144fe21]164        )
165    return unittest.TestSuite(suites)
[06b0138]166
[144fe21]167def fittingSuite():
168    suites = (
[06b0138]169        # Perspectives
[7c487846]170        #  Fitting
[06b0138]171        unittest.makeSuite(FittingPerspectiveTest.FittingPerspectiveTest, 'test'),
172        unittest.makeSuite(FittingWidgetTest.FittingWidgetTest,           'test'),
173        unittest.makeSuite(FittingLogicTest.FittingLogicTest,             'test'),
174        unittest.makeSuite(FittingUtilitiesTest.FittingUtilitiesTest,     'test'),
175        unittest.makeSuite(FitPageTest.FitPageTest,                       'test'),
[72f4834]176        unittest.makeSuite(FittingOptionsTest.FittingOptionsTest,         'test'),
[0595bb7]177        unittest.makeSuite(MultiConstraintTest.MultiConstraintTest,       'test'),
[676f137]178        unittest.makeSuite(ConstraintWidgetTest.ConstraintWidgetTest,     'test'),
[da9a0722]179        unittest.makeSuite(ComplexConstraintTest.ComplexConstraintTest,   'test'),
[144fe21]180        )
181    return unittest.TestSuite(suites)
[676f137]182
[144fe21]183def perspectivesSuite():
184    suites = (
[7c487846]185        #  Invariant
186        unittest.makeSuite(InvariantPerspectiveTest.InvariantPerspectiveTest,  'test'),
[50bfab0]187        #  Inversion
[144fe21]188        #unittest.makeSuite(InversionPerspectiveTest.InversionTest,  'test'),
[676f137]189        )
[06b0138]190    return unittest.TestSuite(suites)
191
192if __name__ == "__main__":
193
[144fe21]194    user_suites = ALL_SUITES
195    # Check if user asked for specific suites:
196    if len(sys.argv) > 1:
197        user_suites = sys.argv[1:]
198
199    runner = unittest.TextTestRunner(verbosity=VERBOSITY)
200    for suite in user_suites:
201        # create the suite object from name
202        try:
203            suite_instance = globals()[suite]()
204            results = runner.run(suite_instance)
205        except KeyError:
206            print("ERROR: Incorrect suite name: %s " % suite)
207            pass
Note: See TracBrowser for help on using the repository browser.