Changeset 144fe21 in sasview for src/sas/qtgui/GUITests.py


Ignore:
Timestamp:
Jul 26, 2018 3:30:15 AM (6 years ago)
Author:
Piotr Rozyczko <rozyczko@…>
Branches:
ESS_GUI, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
Children:
dc71408
Parents:
e793f62
git-author:
Piotr Rozyczko <rozyczko@…> (07/26/18 03:28:51)
git-committer:
Piotr Rozyczko <rozyczko@…> (07/26/18 03:30:15)
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/GUITests.py

    rd0528c4 r144fe21  
    1111by running ``python setup.py install`` in both repositories. 
    1212 
    13 The tests can be run with ``python GUITests.py``, or to get more verbose 
    14 console output (recommended), use ``python GUITests.py -v``. 
     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. 
    1518""" 
     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 
    1635 
    1736# Prepare the general QApplication instance 
     
    83102from Perspectives.Inversion.UnitTesting import InversionPerspectiveTest 
    84103 
    85 def suite(): 
     104def plottingSuite(): 
    86105    suites = ( 
    87106        # Plotting 
     
    101120        unittest.makeSuite(PlotterBaseTest.PlotterBaseTest,           'test'), 
    102121        unittest.makeSuite(PlotterTest.PlotterTest,                   'test'), 
    103  
     122        ) 
     123    return unittest.TestSuite(suites) 
     124 
     125def mainSuite(): 
     126    suites = ( 
    104127        # Main window 
    105128        unittest.makeSuite(DataExplorerTest.DataExplorerTest,  'test'), 
     
    109132        unittest.makeSuite(AboutBoxTest.AboutBoxTest,          'test'), 
    110133        unittest.makeSuite(WelcomePanelTest.WelcomePanelTest,  'test'), 
    111  
    112         # Utilities 
     134        ) 
     135    return unittest.TestSuite(suites) 
     136 
     137def utilitiesSuite(): 
     138    suites = ( 
     139        ## Utilities 
    113140        unittest.makeSuite(TestUtilsTest.TestUtilsTest,           'test'), 
    114141        unittest.makeSuite(SasviewLoggerTest.SasviewLoggerTest,   'test'), 
     
    122149        unittest.makeSuite(AddMultEditorTest.AddMultEditorTest, 'test'), 
    123150        unittest.makeSuite(ReportDialogTest.ReportDialogTest,     'test'), 
    124  
     151        ) 
     152    return unittest.TestSuite(suites) 
     153 
     154def calculatorsSuite(): 
     155    suites = ( 
    125156        # Calculators 
    126157        unittest.makeSuite(KiessigCalculatorTest.KiessigCalculatorTest,                     'test'), 
     
    131162        unittest.makeSuite(ResolutionCalculatorPanelTest.ResolutionCalculatorPanelTest, 'test'), 
    132163        unittest.makeSuite(DataOperationUtilityTest.DataOperationUtilityTest, 'test'), 
    133  
     164        ) 
     165    return unittest.TestSuite(suites) 
     166 
     167def fittingSuite(): 
     168    suites = ( 
    134169        # Perspectives 
    135170        #  Fitting 
     
    143178        unittest.makeSuite(ConstraintWidgetTest.ConstraintWidgetTest,     'test'), 
    144179        unittest.makeSuite(ComplexConstraintTest.ComplexConstraintTest,   'test'), 
    145  
     180        ) 
     181    return unittest.TestSuite(suites) 
     182 
     183def perspectivesSuite(): 
     184    suites = ( 
    146185        #  Invariant 
    147186        unittest.makeSuite(InvariantPerspectiveTest.InvariantPerspectiveTest,  'test'), 
    148187        #  Inversion 
    149         unittest.makeSuite(InversionPerspectiveTest.InversionTest,  'test'), 
     188        #unittest.makeSuite(InversionPerspectiveTest.InversionTest,  'test'), 
    150189        ) 
    151190    return unittest.TestSuite(suites) 
    152191 
    153192if __name__ == "__main__": 
    154     unittest.main(defaultTest="suite") 
    155  
     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 TracChangeset for help on using the changeset viewer.