Author: bugman Date: Fri Jan 4 15:34:14 2008 New Revision: 4322 URL: http://svn.gna.org/viewcvs/relax?rev=4322&view=rev Log: A temporary fix for catching stdout during the execution of all unit tests. The aim is to eventually have stdout collected for each test run and appended to the failure or error message if the test was unsuccessful. Modified: 1.3/test_suite/unit_tests/unit_test_runner.py Modified: 1.3/test_suite/unit_tests/unit_test_runner.py URL: http://svn.gna.org/viewcvs/relax/1.3/test_suite/unit_tests/unit_test_runner.py?rev=4322&r1=4321&r2=4322&view=diff ============================================================================== --- 1.3/test_suite/unit_tests/unit_test_runner.py (original) +++ 1.3/test_suite/unit_tests/unit_test_runner.py Fri Jan 4 15:34:14 2008 @@ -62,7 +62,10 @@ from optparse import OptionParser from textwrap import dedent from copy import copy - +try: + from cStringIO import StringIO +except ImportError: + from StringIO import StringIO # constants @@ -803,8 +806,26 @@ # Run the unit tests and catch the TestResult object. if tests != None and tests.countTestCases() != 0: + # Catch stdout. + buf = StringIO() + sys.stdout = buf + + # Run the test. results = runner.run(tests) result_string = results.wasSuccessful() + + # Restore stdout. + sys.stdout = sys.__stdout__ + + #print "\n\n\n\n\n\n\n" + #print dir(results) + #print "\n\n" + #print results.failures + #print `buf.getvalue()` + + # Close the buffer. + buf.close() + elif tests == None: results=None result_string = 'Error: no test directories found for input module: %s' % self.test_module