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-2012 Edward d'Auvergne                                   # 
  4  #                                                                             # 
  5  # This file is part of the program relax.                                     # 
  6  #                                                                             # 
  7  # relax 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 2 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # relax 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 relax; if not, write to the Free Software                        # 
 19  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   # 
 20  #                                                                             # 
 21  ############################################################################### 
 22   
 23  # Package docstring. 
 24  """The relax system/functional tests.""" 
 25   
 26  # Python module imports. 
 27  from re import search 
 28  from string import split 
 29  from unittest import TestSuite 
 30   
 31  # relax module imports. 
 32  from relax_errors import RelaxError 
 33   
 34  # relax system/functional test module imports. 
 35  from align_tensor import Align_tensor 
 36  from angles import Angles 
 37  from bmrb import Bmrb 
 38  from bruker import Bruker 
 39  from consistency_tests import Ct 
 40  from dasha import Dasha 
 41  from diffusion_tensor import Diffusion_tensor 
 42  from frame_order import Frame_order 
 43  from generic import Generic 
 44  from grace import Grace 
 45  from jw_mapping import Jw 
 46  from load_spins import Load_spins 
 47  from model_elimination import Modelim 
 48  from model_free import Mf 
 49  from model_selection import Modsel 
 50  from mol_res_spin import Mol_res_spin 
 51  from n_state_model import N_state_model 
 52  from noe import Noe 
 53  from noe_restraints import Noe_restraints 
 54  from palmer import Palmer 
 55  from peak_lists import Peak_lists 
 56  from pipes import Pipes 
 57  from rdc import Rdc 
 58  from relax_data import Relax_data 
 59  from relax_fit import Relax_fit 
 60  from results import Results 
 61  from sequence import Sequence 
 62  from state import State 
 63  from structure import Structure 
 64  from test_suite.relax_test_loader import RelaxTestLoader as TestLoader 
 65  from unit_vectors import Unit_vectors 
 66   
 67   
 68  __all__ = ['align_tensor', 
 69             'angles', 
 70             'bmrb', 
 71             'bruker', 
 72             'consistency_tests', 
 73             'dasha' 
 74             'diffusion_tensor', 
 75             'frame_order', 
 76             'generic', 
 77             'grace', 
 78             'jw_mapping', 
 79             'load_spins', 
 80             'model_elimination', 
 81             'model_free', 
 82             'model_selection', 
 83             'n_state_model', 
 84             'noe', 
 85             'noe_restraints', 
 86             'palmer', 
 87             'peak_lists' 
 88             'pipes', 
 89             'rdc', 
 90             'relax_data', 
 91             'relax_fit', 
 92             'results', 
 93             'sequence', 
 94             'state', 
 95             'structure', 
 96             'unit_vectors'] 
 97   
 98   
99 -class System_test_runner:
100 """Class for executing all of the system/functional tests.""" 101
102 - def run(self, tests=None, runner=None):
103 """Run the system/functional tests. 104 105 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. 106 107 108 @keyword tests: The list of system tests to preform. 109 @type tests: list of str 110 @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. 111 @type runner: Test runner instance (TextTestRunner, BaseGUITestRunner subclass, etc.) 112 """ 113 114 # Create an array of test suites (add your new TestCase classes here). 115 suite_array = [] 116 117 # Specific tests. 118 for test in tests: 119 # The entire test class. 120 if not search('\.', test): 121 # Check that the class exists. 122 if test not in globals(): 123 raise RelaxError("The system test class '%s' does not exist." % test) 124 125 # The uninstantiated class object. 126 obj = globals()[test] 127 128 # Add the tests. 129 suite_array.append(TestLoader().loadTestsFromTestCase(obj)) 130 131 # Single system test. 132 else: 133 # Split. 134 row = split(test, '.') 135 136 # Check. 137 if len(row) != 2: 138 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) 139 140 # Unpack. 141 class_name, test_name = row 142 143 # Get the class object. 144 obj = globals()[class_name] 145 146 # Add the test. 147 suite_array.append(TestLoader().loadTestsFromNames([test_name], obj)) 148 149 # All tests. 150 if not tests: 151 suite_array.append(TestLoader().loadTestsFromTestCase(Align_tensor)) 152 suite_array.append(TestLoader().loadTestsFromTestCase(Bmrb)) 153 suite_array.append(TestLoader().loadTestsFromTestCase(Bruker)) 154 suite_array.append(TestLoader().loadTestsFromTestCase(Angles)) 155 suite_array.append(TestLoader().loadTestsFromTestCase(Ct)) 156 suite_array.append(TestLoader().loadTestsFromTestCase(Dasha)) 157 suite_array.append(TestLoader().loadTestsFromTestCase(Diffusion_tensor)) 158 suite_array.append(TestLoader().loadTestsFromTestCase(Frame_order)) 159 suite_array.append(TestLoader().loadTestsFromTestCase(Generic)) 160 suite_array.append(TestLoader().loadTestsFromTestCase(Grace)) 161 suite_array.append(TestLoader().loadTestsFromTestCase(Jw)) 162 suite_array.append(TestLoader().loadTestsFromTestCase(Load_spins)) 163 suite_array.append(TestLoader().loadTestsFromTestCase(Modelim)) 164 suite_array.append(TestLoader().loadTestsFromTestCase(Mf)) 165 suite_array.append(TestLoader().loadTestsFromTestCase(Modsel)) 166 suite_array.append(TestLoader().loadTestsFromTestCase(Mol_res_spin)) 167 suite_array.append(TestLoader().loadTestsFromTestCase(N_state_model)) 168 suite_array.append(TestLoader().loadTestsFromTestCase(Noe)) 169 suite_array.append(TestLoader().loadTestsFromTestCase(Noe_restraints)) 170 suite_array.append(TestLoader().loadTestsFromTestCase(Palmer)) 171 suite_array.append(TestLoader().loadTestsFromTestCase(Peak_lists)) 172 suite_array.append(TestLoader().loadTestsFromTestCase(Pipes)) 173 suite_array.append(TestLoader().loadTestsFromTestCase(Rdc)) 174 suite_array.append(TestLoader().loadTestsFromTestCase(Relax_data)) 175 suite_array.append(TestLoader().loadTestsFromTestCase(Relax_fit)) 176 suite_array.append(TestLoader().loadTestsFromTestCase(Results)) 177 suite_array.append(TestLoader().loadTestsFromTestCase(Sequence)) 178 suite_array.append(TestLoader().loadTestsFromTestCase(State)) 179 suite_array.append(TestLoader().loadTestsFromTestCase(Structure)) 180 suite_array.append(TestLoader().loadTestsFromTestCase(Unit_vectors)) 181 182 # Group all tests together. 183 full_suite = TestSuite(suite_array) 184 185 # Run the test suite. 186 results = runner.run(full_suite) 187 188 # Return the status of the tests. 189 return results.wasSuccessful()
190