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

Source Code for Package test_suite.system_tests

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2006,2008-2010,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 system/functional tests.""" 
 24   
 25  # Python module imports. 
 26  from re import search 
 27  from unittest import TestSuite 
 28   
 29  # relax module imports. 
 30  from lib.errors import RelaxError 
 31   
 32  # relax system/functional test module imports. 
 33  from test_suite.relax_test_loader import RelaxTestLoader as TestLoader 
 34  from test_suite.system_tests.align_tensor import Align_tensor 
 35  from test_suite.system_tests.angles import Angles 
 36  from test_suite.system_tests.bmrb import Bmrb 
 37  from test_suite.system_tests.bruker import Bruker 
 38  from test_suite.system_tests.chemical_shift import Chemical_shift 
 39  from test_suite.system_tests.consistency_tests import Ct 
 40  from test_suite.system_tests.dasha import Dasha 
 41  from test_suite.system_tests.diffusion_tensor import Diffusion_tensor 
 42  from test_suite.system_tests.frame_order import Frame_order 
 43  from test_suite.system_tests.generic import Generic 
 44  from test_suite.system_tests.grace import Grace 
 45  from test_suite.system_tests.interatomic import Interatomic 
 46  from test_suite.system_tests.jw_mapping import Jw 
 47  from test_suite.system_tests.load_spins import Load_spins 
 48  from test_suite.system_tests.model_elimination import Modelim 
 49  from test_suite.system_tests.model_free import Mf 
 50  from test_suite.system_tests.model_selection import Modsel 
 51  from test_suite.system_tests.mol_res_spin import Mol_res_spin 
 52  from test_suite.system_tests.n_state_model import N_state_model 
 53  from test_suite.system_tests.noe import Noe 
 54  from test_suite.system_tests.noe_restraints import Noe_restraints 
 55  from test_suite.system_tests.palmer import Palmer 
 56  from test_suite.system_tests.pcs import Pcs 
 57  from test_suite.system_tests.peak_lists import Peak_lists 
 58  from test_suite.system_tests.pipes import Pipes 
 59  from test_suite.system_tests.rdc import Rdc 
 60  from test_suite.system_tests.relax_data import Relax_data 
 61  from test_suite.system_tests.relax_disp import Relax_disp 
 62  from test_suite.system_tests.relax_fit import Relax_fit 
 63  from test_suite.system_tests.results import Results 
 64  from test_suite.system_tests.selection import Selection 
 65  from test_suite.system_tests.sequence import Sequence 
 66  from test_suite.system_tests.spectrum import Spectrum 
 67  from test_suite.system_tests.state import State 
 68  from test_suite.system_tests.structure import Structure 
 69  from test_suite.system_tests.unit_vectors import Unit_vectors 
 70  from test_suite.system_tests.value import Value 
 71   
 72   
 73  __all__ = ['align_tensor', 
 74             'angles', 
 75             'bmrb', 
 76             'bruker', 
 77             'chemical_shift' 
 78             'consistency_tests', 
 79             'dasha' 
 80             'diffusion_tensor', 
 81             'frame_order', 
 82             'generic', 
 83             'grace', 
 84             'interatomic', 
 85             'jw_mapping', 
 86             'load_spins', 
 87             'model_elimination', 
 88             'model_free', 
 89             'model_selection', 
 90             'n_state_model', 
 91             'noe', 
 92             'noe_restraints', 
 93             'palmer', 
 94             'pcs' 
 95             'peak_lists' 
 96             'pipes', 
 97             'rdc', 
 98             'relax_data', 
 99             'relax_disp', 
100             'relax_fit', 
101             'results', 
102             'scripts', 
103             'selection', 
104             'sequence', 
105             'spectrum', 
106             'state', 
107             'structure', 
108             'unit_vectors', 
109             'value'] 
110   
111   
112 -class System_test_runner:
113 """Class for executing all of the system/functional tests.""" 114
115 - def run(self, tests=None, runner=None):
116 """Run the system/functional tests. 117 118 The system 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. 119 120 121 @keyword tests: The list of system tests to preform. 122 @type tests: list of str 123 @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. 124 @type runner: Test runner instance (TextTestRunner, BaseGUITestRunner subclass, etc.) 125 """ 126 127 # Create an array of test suites (add your new TestCase classes here). 128 suite_array = [] 129 130 # Specific tests. 131 for test in tests: 132 # The entire test class. 133 if not search('\.', test): 134 # Check that the class exists. 135 if test not in globals(): 136 raise RelaxError("The system test class '%s' does not exist." % test) 137 138 # The uninstantiated class object. 139 obj = globals()[test] 140 141 # Add the tests. 142 suite_array.append(TestLoader().loadTestsFromTestCase(obj)) 143 144 # Single system test. 145 else: 146 # Split. 147 row = test.split('.') 148 149 # Check. 150 if len(row) != 2: 151 raise RelaxError("The test '%s' is not in the correct format. It should consist of the test case class, a dot, and the specific test." % test) 152 153 # Unpack. 154 class_name, test_name = row 155 156 # Get the class object. 157 obj = globals()[class_name] 158 159 # Add the test. 160 suite_array.append(TestLoader().loadTestsFromNames([test_name], obj)) 161 162 # All tests. 163 if not tests: 164 suite_array.append(TestLoader().loadTestsFromTestCase(Align_tensor)) 165 suite_array.append(TestLoader().loadTestsFromTestCase(Bmrb)) 166 suite_array.append(TestLoader().loadTestsFromTestCase(Bruker)) 167 suite_array.append(TestLoader().loadTestsFromTestCase(Angles)) 168 suite_array.append(TestLoader().loadTestsFromTestCase(Chemical_shift)) 169 suite_array.append(TestLoader().loadTestsFromTestCase(Ct)) 170 suite_array.append(TestLoader().loadTestsFromTestCase(Dasha)) 171 suite_array.append(TestLoader().loadTestsFromTestCase(Diffusion_tensor)) 172 suite_array.append(TestLoader().loadTestsFromTestCase(Frame_order)) 173 suite_array.append(TestLoader().loadTestsFromTestCase(Generic)) 174 suite_array.append(TestLoader().loadTestsFromTestCase(Grace)) 175 suite_array.append(TestLoader().loadTestsFromTestCase(Interatomic)) 176 suite_array.append(TestLoader().loadTestsFromTestCase(Jw)) 177 suite_array.append(TestLoader().loadTestsFromTestCase(Load_spins)) 178 suite_array.append(TestLoader().loadTestsFromTestCase(Modelim)) 179 suite_array.append(TestLoader().loadTestsFromTestCase(Mf)) 180 suite_array.append(TestLoader().loadTestsFromTestCase(Modsel)) 181 suite_array.append(TestLoader().loadTestsFromTestCase(Mol_res_spin)) 182 suite_array.append(TestLoader().loadTestsFromTestCase(N_state_model)) 183 suite_array.append(TestLoader().loadTestsFromTestCase(Noe)) 184 suite_array.append(TestLoader().loadTestsFromTestCase(Noe_restraints)) 185 suite_array.append(TestLoader().loadTestsFromTestCase(Palmer)) 186 suite_array.append(TestLoader().loadTestsFromTestCase(Pcs)) 187 suite_array.append(TestLoader().loadTestsFromTestCase(Peak_lists)) 188 suite_array.append(TestLoader().loadTestsFromTestCase(Pipes)) 189 suite_array.append(TestLoader().loadTestsFromTestCase(Rdc)) 190 suite_array.append(TestLoader().loadTestsFromTestCase(Relax_data)) 191 suite_array.append(TestLoader().loadTestsFromTestCase(Relax_disp)) 192 suite_array.append(TestLoader().loadTestsFromTestCase(Relax_fit)) 193 suite_array.append(TestLoader().loadTestsFromTestCase(Results)) 194 suite_array.append(TestLoader().loadTestsFromTestCase(Selection)) 195 suite_array.append(TestLoader().loadTestsFromTestCase(Sequence)) 196 suite_array.append(TestLoader().loadTestsFromTestCase(Spectrum)) 197 suite_array.append(TestLoader().loadTestsFromTestCase(State)) 198 suite_array.append(TestLoader().loadTestsFromTestCase(Structure)) 199 suite_array.append(TestLoader().loadTestsFromTestCase(Unit_vectors)) 200 suite_array.append(TestLoader().loadTestsFromTestCase(Value)) 201 202 # Group all tests together. 203 full_suite = TestSuite(suite_array) 204 205 # Run the test suite. 206 results = runner.run(full_suite) 207 208 # Return the status of the tests. 209 return results.wasSuccessful()
210