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 relax_errors import RelaxError 
 28  from string import split 
 29  from unittest import TestSuite 
 30   
 31  # relax GUI test module imports. 
 32  from bmrb import Bmrb 
 33  from model_free import Mf 
 34  from noe import Noe 
 35  from rx import Rx 
 36  from state import State 
 37  from test_suite.relax_test_loader import RelaxTestLoader as TestLoader 
 38   
 39   
 40  __all__ = ['bmrb', 
 41             'model_free', 
 42             'noe', 
 43             'rx', 
 44             'state'] 
 45   
 46   
47 -class GUI_test_runner:
48 """Class for executing all of the GUI tests.""" 49
50 - def run(self, tests=None, runner=None):
51 """Run the GUI tests. 52 53 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. 54 55 56 @keyword tests: The list of GUI tests to preform. 57 @type tests: list of str 58 @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. 59 @type runner: Test runner instance (TextTestRunner, BaseGUITestRunner subclass, etc.) 60 """ 61 62 # Create an array of test suites (add your new TestCase classes here). 63 suite_array = [] 64 65 # Specific tests. 66 for test in tests: 67 # Split. 68 row = split(test, '.') 69 70 # Check. 71 if len(row) != 2: 72 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) 73 74 # Unpack. 75 class_name, test_name = row 76 77 # Get the class object. 78 obj = globals()[class_name] 79 80 # Add the test. 81 suite_array.append(TestLoader().loadTestsFromNames([test_name], obj)) 82 83 # All tests. 84 if not tests: 85 suite_array.append(TestLoader().loadTestsFromTestCase(Bmrb)) 86 suite_array.append(TestLoader().loadTestsFromTestCase(Mf)) 87 suite_array.append(TestLoader().loadTestsFromTestCase(Noe)) 88 suite_array.append(TestLoader().loadTestsFromTestCase(Rx)) 89 suite_array.append(TestLoader().loadTestsFromTestCase(State)) 90 91 # Group all tests together. 92 full_suite = TestSuite(suite_array) 93 94 # Run the test suite. 95 results = runner.run(full_suite) 96 97 # Return the status of the tests. 98 return results.wasSuccessful()
99