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@…>, 2 years ago

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

  • Property mode set to 100644
File size: 8.9 KB
Line 
1import unittest
2import sys
3from PyQt5 import QtGui
4from PyQt5 import QtWidgets
5
6"""
7Unit tests for the QT GUI
8=========================
9
10In order to run the tests, first install SasView and sasmodels to site-packages
11by running ``python setup.py install`` in both repositories.
12
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.
18"""
19
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
36# Prepare the general QApplication instance
37app = QtWidgets.QApplication(sys.argv)
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
47## Plotting
48from Plotting.UnitTesting import AddTextTest
49from Plotting.UnitTesting import PlotHelperTest
50from Plotting.UnitTesting import WindowTitleTest
51from Plotting.UnitTesting import ScalePropertiesTest
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
60from Plotting.UnitTesting import PlotterBaseTest
61from Plotting.UnitTesting import PlotterTest
62from Plotting.UnitTesting import Plotter2DTest
63
64# Calculators
65from Calculators.UnitTesting import KiessigCalculatorTest
66from Calculators.UnitTesting import DensityCalculatorTest
67from Calculators.UnitTesting import GenericScatteringCalculatorTest
68from Calculators.UnitTesting import SLDCalculatorTest
69from Calculators.UnitTesting import SlitSizeCalculatorTest
70from Calculators.UnitTesting import ResolutionCalculatorPanelTest
71from Calculators.UnitTesting import DataOperationUtilityTest
72
73# Utilities
74from Utilities.UnitTesting import GuiUtilsTest
75from Utilities.UnitTesting import SasviewLoggerTest
76from Utilities.UnitTesting import GridPanelTest
77from Utilities.UnitTesting import ModelEditorTest
78from Utilities.UnitTesting import PluginDefinitionTest
79from Utilities.UnitTesting import TabbedModelEditorTest
80from Utilities.UnitTesting import AddMultEditorTest
81from Utilities.UnitTesting import ReportDialogTest
82
83# Unit Testing
84from UnitTesting import TestUtilsTest
85
86# Perspectives
87#  Fitting
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
93from Perspectives.Fitting.UnitTesting import FittingOptionsTest
94from Perspectives.Fitting.UnitTesting import MultiConstraintTest
95from Perspectives.Fitting.UnitTesting import ComplexConstraintTest
96from Perspectives.Fitting.UnitTesting import ConstraintWidgetTest
97
98#  Invariant
99from Perspectives.Invariant.UnitTesting import InvariantPerspectiveTest
100
101#  Inversion
102from Perspectives.Inversion.UnitTesting import InversionPerspectiveTest
103
104def plottingSuite():
105    suites = (
106        # Plotting
107        unittest.makeSuite(Plotter2DTest.Plotter2DTest,               'test'),
108        unittest.makeSuite(PlotHelperTest.PlotHelperTest,             'test'),
109        unittest.makeSuite(AddTextTest.AddTextTest,                   'test'),
110        unittest.makeSuite(WindowTitleTest.WindowTitleTest,           'test'),
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'),
120        unittest.makeSuite(PlotterBaseTest.PlotterBaseTest,           'test'),
121        unittest.makeSuite(PlotterTest.PlotterTest,                   'test'),
122        )
123    return unittest.TestSuite(suites)
124
125def mainSuite():
126    suites = (
127        # Main window
128        unittest.makeSuite(DataExplorerTest.DataExplorerTest,  'test'),
129        unittest.makeSuite(DroppableDataLoadWidgetTest.DroppableDataLoadWidgetTest, 'test'),
130        unittest.makeSuite(MainWindowTest.MainWindowTest,      'test'),
131        unittest.makeSuite(GuiManagerTest.GuiManagerTest,      'test'),
132        unittest.makeSuite(AboutBoxTest.AboutBoxTest,          'test'),
133        unittest.makeSuite(WelcomePanelTest.WelcomePanelTest,  'test'),
134        )
135    return unittest.TestSuite(suites)
136
137def utilitiesSuite():
138    suites = (
139        ## Utilities
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'),
145        unittest.makeSuite(GridPanelTest.BatchOutputPanelTest,    'test'),
146        unittest.makeSuite(ModelEditorTest.ModelEditorTest,            'test'),
147        unittest.makeSuite(PluginDefinitionTest.PluginDefinitionTest,  'test'),
148        unittest.makeSuite(TabbedModelEditorTest.TabbedModelEditorTest,'test'),
149        unittest.makeSuite(AddMultEditorTest.AddMultEditorTest, 'test'),
150        unittest.makeSuite(ReportDialogTest.ReportDialogTest,     'test'),
151        )
152    return unittest.TestSuite(suites)
153
154def calculatorsSuite():
155    suites = (
156        # Calculators
157        unittest.makeSuite(KiessigCalculatorTest.KiessigCalculatorTest,                     'test'),
158        unittest.makeSuite(DensityCalculatorTest.DensityCalculatorTest,                     'test'),
159        unittest.makeSuite(GenericScatteringCalculatorTest.GenericScatteringCalculatorTest, 'test'),
160        unittest.makeSuite(SLDCalculatorTest.SLDCalculatorTest, 'test'),
161        unittest.makeSuite(SlitSizeCalculatorTest.SlitSizeCalculatorTest, 'test'),
162        unittest.makeSuite(ResolutionCalculatorPanelTest.ResolutionCalculatorPanelTest, 'test'),
163        unittest.makeSuite(DataOperationUtilityTest.DataOperationUtilityTest, 'test'),
164        )
165    return unittest.TestSuite(suites)
166
167def fittingSuite():
168    suites = (
169        # Perspectives
170        #  Fitting
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'),
176        unittest.makeSuite(FittingOptionsTest.FittingOptionsTest,         'test'),
177        unittest.makeSuite(MultiConstraintTest.MultiConstraintTest,       'test'),
178        unittest.makeSuite(ConstraintWidgetTest.ConstraintWidgetTest,     'test'),
179        unittest.makeSuite(ComplexConstraintTest.ComplexConstraintTest,   'test'),
180        )
181    return unittest.TestSuite(suites)
182
183def perspectivesSuite():
184    suites = (
185        #  Invariant
186        unittest.makeSuite(InvariantPerspectiveTest.InvariantPerspectiveTest,  'test'),
187        #  Inversion
188        #unittest.makeSuite(InversionPerspectiveTest.InversionTest,  'test'),
189        )
190    return unittest.TestSuite(suites)
191
192if __name__ == "__main__":
193
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.