Author: bugman Date: Wed Oct 5 15:44:33 2011 New Revision: 14789 URL: http://svn.gna.org/viewcvs/relax?rev=14789&view=rev Log: Implemented some new classes to allow better control of the test suite from the GUI. The GuiTestResult and GuiTestRunner classes have been added to the relax_test_runner module, and these are used rather than RelaxTestResult and RelaxTestRunner if the from_gui flag is sent to the main Test_suite_runner class. Modified: 1.3/test_suite/relax_test_runner.py 1.3/test_suite/test_suite_runner.py Modified: 1.3/test_suite/relax_test_runner.py URL: http://svn.gna.org/viewcvs/relax/1.3/test_suite/relax_test_runner.py?rev=14789&r1=14788&r2=14789&view=diff ============================================================================== --- 1.3/test_suite/relax_test_runner.py (original) +++ 1.3/test_suite/relax_test_runner.py Wed Oct 5 15:44:33 2011 @@ -23,6 +23,7 @@ # Python module imports. import sys from unittest import TextTestResult, TextTestRunner +import wx try: from cStringIO import StringIO except ImportError: @@ -100,6 +101,22 @@ +class GuiTestResult(RelaxTestResult): + """A replacement for the TextTestResult class for the GUI.""" + + def stopTest(self, test): + """Override of the RelaxTestResult.stopTest() method. + + The end of STDOUT and STDERR capture occurs here. + """ + + # Execute the RelaxTestResult.stopTest() method. + super(RelaxTestResult, self).stopTest(test) + + # Yield to allow the GUI to be updated. + wx.GetApp().Yield(True) + + class RelaxTestRunner(TextTestRunner): """A replacement unittest runner. @@ -108,8 +125,15 @@ output to the failure and error reports normally generated by TextTestRunner. """ - def _makeResult(self): - """Override of the TextTestRunner._makeResult() method.""" + resultclass = RelaxTestResult - # Run the tests. - return RelaxTestResult(self.stream, self.descriptions, self.verbosity) + + +class GuiTestRunner(TextTestRunner): + """A replacement unittest runner. + + This runner is designed to catch STDOUT during the execution of each test and to prepend the + output to the failure and error reports normally generated by TextTestRunner. + """ + + resultclass = GuiTestResult Modified: 1.3/test_suite/test_suite_runner.py URL: http://svn.gna.org/viewcvs/relax/1.3/test_suite/test_suite_runner.py?rev=14789&r1=14788&r2=14789&view=diff ============================================================================== --- 1.3/test_suite/test_suite_runner.py (original) +++ 1.3/test_suite/test_suite_runner.py Wed Oct 5 15:44:33 2011 @@ -37,7 +37,7 @@ from unit_tests.unit_test_runner import Unit_test_runner # relax module imports. -from relax_test_runner import RelaxTestRunner +from relax_test_runner import GuiTestRunner, RelaxTestRunner from status import Status; status = Status() @@ -50,14 +50,16 @@ - GUI tests. """ - def __init__(self, tests=[]): + def __init__(self, tests=[], from_gui=False): """Store the list of tests to preform. The 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. - @keyword tests: The list of tests to preform. If left at [], then all tests will be run. - @type tests: list of str + @keyword tests: The list of tests to preform. If left at [], then all tests will be run. + @type tests: list of str + @keyword from_gui: A flag which indicates if the tests are being run from the GUI or not. + @type from_gui: bool """ # Store the args. @@ -67,7 +69,10 @@ status.skip = [] # Set up the test runner. - self.runner = RelaxTestRunner(stream=sys.stdout) + if from_gui: + self.runner = GuiTestRunner(stream=sys.stdout) + else: + self.runner = RelaxTestRunner(stream=sys.stdout) def run_all_tests(self):