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.                                     # 
  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 GUI 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 GUI test module imports. 
 35  from bmrb import Bmrb 
 36  from consistency_tests import Ct 
 37  from dead_uf_pages import Dead_uf_pages 
 38  from frame_order import Frame_order 
 39  from jw_mapping import Jw_mapping 
 40  from model_free import Mf 
 41  from n_state_model import N_state_model 
 42  from noe import Noe 
 43  from pipes import Pipes 
 44  from rx import Rx 
 45  from state import State 
 46  from test_suite.relax_test_loader import RelaxTestLoader as TestLoader 
 47   
 48   
 49  __all__ = ['bmrb', 
 50             'consistency_tests', 
 51             'jw_mapping', 
 52             'model_free', 
 53             'n_state_model', 
 54             'noe', 
 55             'pipes', 
 56             'rx', 
 57             'state'] 
 58   
 59   
60 -class GUI_test_runner:
61 """Class for executing all of the GUI tests.""" 62
63 - def run(self, tests=None, runner=None):
64 """Run the GUI tests. 65 66 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. 67 68 69 @keyword tests: The list of GUI tests to preform. 70 @type tests: list of str 71 @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. 72 @type runner: Test runner instance (TextTestRunner, BaseGUITestRunner subclass, etc.) 73 """ 74 75 # Create an array of test suites (add your new TestCase classes here). 76 suite_array = [] 77 78 # Specific tests. 79 for test in tests: 80 # The entire test class. 81 if not search('\.', test): 82 # Check that the class exists. 83 if test not in globals(): 84 raise RelaxError("The GUI test class '%s' does not exist." % test) 85 86 # The uninstantiated class object. 87 obj = globals()[test] 88 89 # Add the tests. 90 suite_array.append(TestLoader().loadTestsFromTestCase(obj)) 91 92 # Single system test. 93 else: 94 # Split. 95 row = split(test, '.') 96 97 # Check. 98 if len(row) != 2: 99 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) 100 101 # Unpack. 102 class_name, test_name = row 103 104 # Get the class object. 105 obj = globals()[class_name] 106 107 # Add the test. 108 suite_array.append(TestLoader().loadTestsFromNames([test_name], obj)) 109 110 # All tests. 111 if not tests: 112 suite_array.append(TestLoader().loadTestsFromTestCase(Bmrb)) 113 suite_array.append(TestLoader().loadTestsFromTestCase(Ct)) 114 suite_array.append(TestLoader().loadTestsFromTestCase(Dead_uf_pages)) 115 suite_array.append(TestLoader().loadTestsFromTestCase(Frame_order)) 116 suite_array.append(TestLoader().loadTestsFromTestCase(Jw_mapping)) 117 suite_array.append(TestLoader().loadTestsFromTestCase(Mf)) 118 suite_array.append(TestLoader().loadTestsFromTestCase(N_state_model)) 119 suite_array.append(TestLoader().loadTestsFromTestCase(Noe)) 120 suite_array.append(TestLoader().loadTestsFromTestCase(Pipes)) 121 suite_array.append(TestLoader().loadTestsFromTestCase(Rx)) 122 suite_array.append(TestLoader().loadTestsFromTestCase(State)) 123 124 # Group all tests together. 125 full_suite = TestSuite(suite_array) 126 127 # Run the test suite. 128 results = runner.run(full_suite) 129 130 # Return the status of the tests. 131 return results.wasSuccessful()
132