source: sasview/src/sas/qtgui/GUITests.py @ a944beb

ESS_GUIESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_openclESS_GUI_sync_sascalc
Last change on this file since a944beb was 712db9e, checked in by rozyczko <piotr.rozyczko@…>, 6 years ago

Set pointer to the correct set of data in batch fitting.

  • Property mode set to 100644
File size: 9.7 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``
[32f6cdd]17"""
18
[144fe21]19# Llist of all suite names. Every time a new suite is added, its name should
20# also be added here
21ALL_SUITES = [
22    'calculatorsSuite',
23    'mainSuite',
24    'fittingSuite',
25    'plottingSuite',
26    'utilitiesSuite',
27    'perspectivesSuite',
28    ]
29
[464cd07]30# Prepare the general QApplication instance
[4992ff2]31app = QtWidgets.QApplication(sys.argv)
[06b0138]32
33# Main Window
34from MainWindow.UnitTesting import AboutBoxTest
35from MainWindow.UnitTesting import DataExplorerTest
36from MainWindow.UnitTesting import WelcomePanelTest
37from MainWindow.UnitTesting import DroppableDataLoadWidgetTest
38from MainWindow.UnitTesting import GuiManagerTest
39from MainWindow.UnitTesting import MainWindowTest
40
[53c771e]41## Plotting
[06b0138]42from Plotting.UnitTesting import AddTextTest
43from Plotting.UnitTesting import PlotHelperTest
44from Plotting.UnitTesting import WindowTitleTest
[53c771e]45from Plotting.UnitTesting import ScalePropertiesTest
[06b0138]46from Plotting.UnitTesting import SetGraphRangeTest
47from Plotting.UnitTesting import LinearFitTest
48from Plotting.UnitTesting import PlotPropertiesTest
49from Plotting.UnitTesting import PlotUtilitiesTest
50from Plotting.UnitTesting import ColorMapTest
51from Plotting.UnitTesting import BoxSumTest
52from Plotting.UnitTesting import SlicerModelTest
53from Plotting.UnitTesting import SlicerParametersTest
[53c771e]54from Plotting.UnitTesting import PlotterBaseTest
55from Plotting.UnitTesting import PlotterTest
56from Plotting.UnitTesting import Plotter2DTest
[06b0138]57
58# Calculators
59from Calculators.UnitTesting import KiessigCalculatorTest
60from Calculators.UnitTesting import DensityCalculatorTest
61from Calculators.UnitTesting import GenericScatteringCalculatorTest
[464cd07]62from Calculators.UnitTesting import SLDCalculatorTest
63from Calculators.UnitTesting import SlitSizeCalculatorTest
[01cda57]64from Calculators.UnitTesting import ResolutionCalculatorPanelTest
[d5c5d3d]65from Calculators.UnitTesting import DataOperationUtilityTest
[06b0138]66
67# Utilities
68from Utilities.UnitTesting import GuiUtilsTest
69from Utilities.UnitTesting import SasviewLoggerTest
[3b3b40b]70from Utilities.UnitTesting import GridPanelTest
71from Utilities.UnitTesting import ModelEditorTest
72from Utilities.UnitTesting import PluginDefinitionTest
73from Utilities.UnitTesting import TabbedModelEditorTest
[01ef3f7]74from Utilities.UnitTesting import AddMultEditorTest
[57be490]75from Utilities.UnitTesting import ReportDialogTest
[06b0138]76
77# Unit Testing
78from UnitTesting import TestUtilsTest
79
80# Perspectives
[7c487846]81#  Fitting
[06b0138]82from Perspectives.Fitting.UnitTesting import FittingWidgetTest
83from Perspectives.Fitting.UnitTesting import FittingPerspectiveTest
84from Perspectives.Fitting.UnitTesting import FittingLogicTest
85from Perspectives.Fitting.UnitTesting import FittingUtilitiesTest
86from Perspectives.Fitting.UnitTesting import FitPageTest
[72f4834]87from Perspectives.Fitting.UnitTesting import FittingOptionsTest
[0595bb7]88from Perspectives.Fitting.UnitTesting import MultiConstraintTest
[da9a0722]89from Perspectives.Fitting.UnitTesting import ComplexConstraintTest
[676f137]90from Perspectives.Fitting.UnitTesting import ConstraintWidgetTest
[0595bb7]91
[7c487846]92#  Invariant
93from Perspectives.Invariant.UnitTesting import InvariantPerspectiveTest
[06b0138]94
[676f137]95#  Inversion
96from Perspectives.Inversion.UnitTesting import InversionPerspectiveTest
97
[144fe21]98def plottingSuite():
[06b0138]99    suites = (
100        # Plotting
101        unittest.makeSuite(Plotter2DTest.Plotter2DTest,               'test'),
[53c771e]102        unittest.makeSuite(PlotHelperTest.PlotHelperTest,             'test'),
[06b0138]103        unittest.makeSuite(AddTextTest.AddTextTest,                   'test'),
[53c771e]104        unittest.makeSuite(WindowTitleTest.WindowTitleTest,           'test'),
[06b0138]105        unittest.makeSuite(ScalePropertiesTest.ScalePropertiesTest,   'test'),
106        unittest.makeSuite(SetGraphRangeTest.SetGraphRangeTest,       'test'),
107        unittest.makeSuite(LinearFitTest.LinearFitTest,               'test'),
108        unittest.makeSuite(PlotPropertiesTest.PlotPropertiesTest,     'test'),
109        unittest.makeSuite(PlotUtilitiesTest.PlotUtilitiesTest,       'test'),
110        unittest.makeSuite(ColorMapTest.ColorMapTest,                 'test'),
111        unittest.makeSuite(BoxSumTest.BoxSumTest,                     'test'),
112        unittest.makeSuite(SlicerModelTest.SlicerModelTest,           'test'),
113        unittest.makeSuite(SlicerParametersTest.SlicerParametersTest, 'test'),
[53c771e]114        unittest.makeSuite(PlotterBaseTest.PlotterBaseTest,           'test'),
115        unittest.makeSuite(PlotterTest.PlotterTest,                   'test'),
[144fe21]116        )
117    return unittest.TestSuite(suites)
[06b0138]118
[144fe21]119def mainSuite():
120    suites = (
[06b0138]121        # Main window
122        unittest.makeSuite(DataExplorerTest.DataExplorerTest,  'test'),
[f4a1433]123        unittest.makeSuite(DroppableDataLoadWidgetTest.DroppableDataLoadWidgetTest, 'test'),
[06b0138]124        unittest.makeSuite(MainWindowTest.MainWindowTest,      'test'),
[53c771e]125        unittest.makeSuite(GuiManagerTest.GuiManagerTest,      'test'),
126        unittest.makeSuite(AboutBoxTest.AboutBoxTest,          'test'),
127        unittest.makeSuite(WelcomePanelTest.WelcomePanelTest,  'test'),
[144fe21]128        )
129    return unittest.TestSuite(suites)
[06b0138]130
[144fe21]131def utilitiesSuite():
132    suites = (
133        ## Utilities
[0261bc1]134        unittest.makeSuite(TestUtilsTest.TestUtilsTest,           'test'),
135        unittest.makeSuite(SasviewLoggerTest.SasviewLoggerTest,   'test'),
136        unittest.makeSuite(GuiUtilsTest.GuiUtilsTest,             'test'),
137        unittest.makeSuite(GuiUtilsTest.DoubleValidatorTest,      'test'),
138        unittest.makeSuite(GuiUtilsTest.HashableStandardItemTest, 'test'),
[3b3b40b]139        unittest.makeSuite(GridPanelTest.BatchOutputPanelTest,    'test'),
140        unittest.makeSuite(ModelEditorTest.ModelEditorTest,            'test'),
141        unittest.makeSuite(PluginDefinitionTest.PluginDefinitionTest,  'test'),
142        unittest.makeSuite(TabbedModelEditorTest.TabbedModelEditorTest,'test'),
[01ef3f7]143        unittest.makeSuite(AddMultEditorTest.AddMultEditorTest, 'test'),
[57be490]144        unittest.makeSuite(ReportDialogTest.ReportDialogTest,     'test'),
[144fe21]145        )
146    return unittest.TestSuite(suites)
[06b0138]147
[144fe21]148def calculatorsSuite():
149    suites = (
[06b0138]150        # Calculators
151        unittest.makeSuite(KiessigCalculatorTest.KiessigCalculatorTest,                     'test'),
152        unittest.makeSuite(DensityCalculatorTest.DensityCalculatorTest,                     'test'),
153        unittest.makeSuite(GenericScatteringCalculatorTest.GenericScatteringCalculatorTest, 'test'),
[464cd07]154        unittest.makeSuite(SLDCalculatorTest.SLDCalculatorTest, 'test'),
155        unittest.makeSuite(SlitSizeCalculatorTest.SlitSizeCalculatorTest, 'test'),
[01cda57]156        unittest.makeSuite(ResolutionCalculatorPanelTest.ResolutionCalculatorPanelTest, 'test'),
[d5c5d3d]157        unittest.makeSuite(DataOperationUtilityTest.DataOperationUtilityTest, 'test'),
[144fe21]158        )
159    return unittest.TestSuite(suites)
[06b0138]160
[144fe21]161def fittingSuite():
162    suites = (
[06b0138]163        # Perspectives
[7c487846]164        #  Fitting
[06b0138]165        unittest.makeSuite(FittingPerspectiveTest.FittingPerspectiveTest, 'test'),
166        unittest.makeSuite(FittingWidgetTest.FittingWidgetTest,           'test'),
167        unittest.makeSuite(FittingLogicTest.FittingLogicTest,             'test'),
168        unittest.makeSuite(FittingUtilitiesTest.FittingUtilitiesTest,     'test'),
169        unittest.makeSuite(FitPageTest.FitPageTest,                       'test'),
[72f4834]170        unittest.makeSuite(FittingOptionsTest.FittingOptionsTest,         'test'),
[0595bb7]171        unittest.makeSuite(MultiConstraintTest.MultiConstraintTest,       'test'),
[676f137]172        unittest.makeSuite(ConstraintWidgetTest.ConstraintWidgetTest,     'test'),
[da9a0722]173        unittest.makeSuite(ComplexConstraintTest.ComplexConstraintTest,   'test'),
[144fe21]174        )
175    return unittest.TestSuite(suites)
[676f137]176
[144fe21]177def perspectivesSuite():
178    suites = (
[7c487846]179        #  Invariant
180        unittest.makeSuite(InvariantPerspectiveTest.InvariantPerspectiveTest,  'test'),
[50bfab0]181        #  Inversion
[ccd2b87]182        unittest.makeSuite(InversionPerspectiveTest.InversionTest,  'test'),
[676f137]183        )
[06b0138]184    return unittest.TestSuite(suites)
185
186if __name__ == "__main__":
187
[144fe21]188    user_suites = ALL_SUITES
189    # Check if user asked for specific suites:
190    if len(sys.argv) > 1:
191        user_suites = sys.argv[1:]
[7dd309a]192    errors = {}
[144fe21]193    for suite in user_suites:
194        # create the suite object from name
195        try:
[7dd309a]196
[144fe21]197            suite_instance = globals()[suite]()
[7dd309a]198            result=unittest.TextTestResult(sys.stdout,True,True)
199            print("\nRunning %d test cases for %s"%(suite_instance.countTestCases(), suite))
200            result.buffer=True
201            suite_instance.run(result)
202
203            if not result.wasSuccessful():
204                if len(result.errors) or len(result.failures):
205                    errors[suite] = (result.errors, result.failures)
206                if len(result.errors):
207                    print("\n============ Errors disovered ===================")
208                if len(result.failures):
209                    print("\n============ Failures disovered =================")
210            else:
211                print("\nAll tests successful")
212
[712db9e]213        except KeyError as ex:
[7dd309a]214            print("Failure : %s "%str(ex))
[144fe21]215            print("ERROR: Incorrect suite name: %s " % suite)
216            pass
[7dd309a]217
218    if len(errors.keys())>0:
219        for suite, errors in errors.items():
220            for r in errors[0]:
221                    print("\nSuite: %s had following errors:\n %s : %s"%(suite, r[0], r[1]))
222            for r in errors[1]:
223                    print("\nSuite: %s had following failures:\n %s : %s"%(suite, r[0], r[1]))
224            print("=================================================")
Note: See TracBrowser for help on using the repository browser.