Author: bugman Date: Fri Apr 25 17:14:23 2008 New Revision: 6012 URL: http://svn.gna.org/viewcvs/relax?rev=6012&view=rev Log: Improvements to the STDOUT and STDERR handling in the _RelaxTestResult class. Now STDOUT and STDERR are stored simultaneously within the same StringIO() instance so that the streams are merged into one. This means that the test suite tests print out the messages as they would appear on screen. Modified: 1.3/test_suite/relax_test_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=6012&r1=6011&r2=6012&view=diff ============================================================================== --- 1.3/test_suite/relax_test_runner.py (original) +++ 1.3/test_suite/relax_test_runner.py Fri Apr 25 17:14:23 2008 @@ -39,16 +39,13 @@ def startTest(self, test): """Override of the _TextTestResult.startTest() method. - The start of STDOUT capture occurs here. + The start of STDOUT and STDERR capture occurs here. """ - # Catch stdout. - self.capt_stdout = StringIO() - sys.stdout = self.capt_stdout - - # Catch stderr. - self.capt_stderr = StringIO() - sys.stderr = self.capt_stderr + # Catch stdout and stderr. + self.capt = StringIO() + sys.stdout = self.capt + sys.stderr = self.capt # Execute the normal startTest method. _TextTestResult.startTest(self, test) @@ -57,43 +54,38 @@ def stopTest(self, test): """Override of the TestResult.stopTest() method. - The end of STDOUT capture occurs here. + The end of STDOUT and STDERR capture occurs here. """ - # Restore stdout. + # Restore stdout and stderr. sys.stdout = sys.__stdout__ + sys.stderr = sys.__stderr__ def addError(self, test, err): """Override of the TestResult.addError() method. - The STDOUT captured text is prepended to the error text here. + The STDOUT and STDERR captured text is prepended to the error text here. """ # Execute the normal addError method. _TextTestResult.addError(self, test, err) - # Prepend STDERR to the second element of the tuple. - self.errors[-1] = (self.errors[-1][0], self.capt_stderr.getvalue() + self.errors[-1][1]) - - # Prepend STDOUT to the second element of the tuple. - self.errors[-1] = (self.errors[-1][0], self.capt_stdout.getvalue() + self.errors[-1][1]) + # Prepend the STDOUT and STDERR messages to the second element of the tuple. + self.errors[-1] = (self.errors[-1][0], self.capt.getvalue() + self.errors[-1][1]) def addFailure(self, test, err): """Override of the TestResult.addFailure() method. - The STDOUT captured text is prepended to the error text here. + The STDOUT and STDERR captured text is prepended to the failure text here. """ # Execute the normal addFailure method. _TextTestResult.addFailure(self, test, err) - # Prepend STDERR to the second element of the tuple. - self.failures[-1] = (self.failures[-1][0], self.capt_stderr.getvalue() + self.failures[-1][1]) - - # Prepend STDOUT to the second element of the tuple. - self.failures[-1] = (self.failures[-1][0], self.capt_stdout.getvalue() + self.failures[-1][1]) + # Prepend the STDOUT and STDERR messages to the second element of the tuple. + self.failures[-1] = (self.failures[-1][0], self.capt.getvalue() + self.failures[-1][1])