Package test_suite :: Package gui_tests
[hide private]
[frames] | no frames]

Source Code for Package test_suite.gui_tests

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2006-2012 Edward d'Auvergne                                   # 
  4  #                                                                             # 
  5  # This file is part of the program relax (http://www.nmr-relax.com).          # 
  6  #                                                                             # 
  7  # This program is free software: you can redistribute it and/or modify        # 
  8  # it under the terms of the GNU General Public License as published by        # 
  9  # the Free Software Foundation, either version 3 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # This program is distributed in the hope that it will be useful,             # 
 13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 15  # GNU General Public License for more details.                                # 
 16  #                                                                             # 
 17  # You should have received a copy of the GNU General Public License           # 
 18  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
 19  #                                                                             # 
 20  ############################################################################### 
 21   
 22  # Package docstring. 
 23  """The relax GUI tests.""" 
 24   
 25  # Python module imports. 
 26  from re import search 
 27  from unittest import TestSuite 
 28  import wx 
 29   
 30  # relax module imports. 
 31  from relax_errors import RelaxError 
 32   
 33  # relax GUI test module imports. 
 34  from test_suite.gui_tests.bmrb import Bmrb 
 35  from test_suite.gui_tests.bruker import Bruker 
 36  from test_suite.gui_tests.consistency_tests import Ct 
 37  from test_suite.gui_tests.dead_uf_pages import Dead_uf_pages 
 38  from test_suite.gui_tests.frame_order import Frame_order 
 39  from test_suite.gui_tests.interatomic import Interatomic 
 40  from test_suite.gui_tests.jw_mapping import Jw_mapping 
 41  from test_suite.gui_tests.model_free import Mf 
 42  from test_suite.gui_tests.n_state_model import N_state_model 
 43  from test_suite.gui_tests.noe import Noe 
 44  from test_suite.gui_tests.pipes import Pipes 
 45  from test_suite.gui_tests.rx import Rx 
 46  from test_suite.gui_tests.state import State 
 47  from test_suite.gui_tests.test_user_functions import User_functions 
 48  from test_suite.relax_test_loader import RelaxTestLoader as TestLoader 
 49   
 50   
 51  __all__ = ['bmrb', 
 52             'consistency_tests', 
 53             'interatomic', 
 54             'jw_mapping', 
 55             'model_free', 
 56             'n_state_model', 
 57             'noe', 
 58             'pipes', 
 59             'rx', 
 60             'state'] 
 61   
 62   
63 -class GUI_test_runner:
64 """Class for executing all of the GUI tests.""" 65
66 - def run(self, tests=None, runner=None):
67 """Run the GUI tests. 68 69 The GUI test list should be something like ['N_state_model.test_stereochem_analysis']. The first part is the imported test case class, the second is the specific test. 70 71 72 @keyword tests: The list of GUI tests to preform. 73 @type tests: list of str 74 @keyword runner: A test runner such as TextTestRunner. For an example of how to write a test runner see the python documentation for TextTestRunner in the python source. 75 @type runner: Test runner instance (TextTestRunner, BaseGUITestRunner subclass, etc.) 76 """ 77 78 # Create an array of test suites (add your new TestCase classes here). 79 suite_array = [] 80 81 # Specific tests. 82 for test in tests: 83 # The entire test class. 84 if not search('\.', test): 85 # Check that the class exists. 86 if test not in globals(): 87 raise RelaxError("The GUI test class '%s' does not exist." % test) 88 89 # The uninstantiated class object. 90 obj = globals()[test] 91 92 # Add the tests. 93 suite_array.append(TestLoader().loadTestsFromTestCase(obj)) 94 95 # Single system test. 96 else: 97 # Split. 98 row = test.split('.') 99 100 # Check. 101 if len(row) != 2: 102 raise RelaxError("The GUI test '%s' is not in the correct format. It should consist of the test case class, a dot, and the specific test." % test) 103 104 # Unpack. 105 class_name, test_name = row 106 107 # Get the class object. 108 obj = globals()[class_name] 109 110 # Add the test. 111 suite_array.append(TestLoader().loadTestsFromNames([test_name], obj)) 112 113 # All tests. 114 if not tests: 115 suite_array.append(TestLoader().loadTestsFromTestCase(Bmrb)) 116 suite_array.append(TestLoader().loadTestsFromTestCase(Bruker)) 117 suite_array.append(TestLoader().loadTestsFromTestCase(Ct)) 118 suite_array.append(TestLoader().loadTestsFromTestCase(Dead_uf_pages)) 119 suite_array.append(TestLoader().loadTestsFromTestCase(Frame_order)) 120 suite_array.append(TestLoader().loadTestsFromTestCase(Interatomic)) 121 suite_array.append(TestLoader().loadTestsFromTestCase(Jw_mapping)) 122 suite_array.append(TestLoader().loadTestsFromTestCase(Mf)) 123 suite_array.append(TestLoader().loadTestsFromTestCase(N_state_model)) 124 suite_array.append(TestLoader().loadTestsFromTestCase(Noe)) 125 suite_array.append(TestLoader().loadTestsFromTestCase(Pipes)) 126 suite_array.append(TestLoader().loadTestsFromTestCase(Rx)) 127 suite_array.append(TestLoader().loadTestsFromTestCase(State)) 128 suite_array.append(TestLoader().loadTestsFromTestCase(User_functions)) 129 130 # Group all tests together. 131 full_suite = TestSuite(suite_array) 132 133 # Run the test suite. 134 results = runner.run(full_suite) 135 136 # Return the status of the tests. 137 return results.wasSuccessful()
138