mailr4326 - in /1.3/test_suite: relax_test_runner.py unit_tests/unit_test_runner.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on January 04, 2008 - 17:33:
Author: bugman
Date: Fri Jan  4 17:33:45 2008
New Revision: 4326

URL: http://svn.gna.org/viewcvs/relax?rev=4326&view=rev
Log:
Shifted the IO redirection into the RelaxTestRunner.run() method.

This is a temporary change.


Modified:
    1.3/test_suite/relax_test_runner.py
    1.3/test_suite/unit_tests/unit_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=4326&r1=4325&r2=4326&view=diff
==============================================================================
--- 1.3/test_suite/relax_test_runner.py (original)
+++ 1.3/test_suite/relax_test_runner.py Fri Jan  4 17:33:45 2008
@@ -21,7 +21,12 @@
 
###############################################################################
 
 # Python module imports.
+import sys
 from unittest import TextTestRunner
+try:
+    from cStringIO import StringIO
+except ImportError:
+    from StringIO import StringIO
 
 
 class RelaxTestRunner(TextTestRunner):
@@ -30,3 +35,28 @@
     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.
     """
+
+    def run(self, test):
+        """Override of the TextTestRunner.run() method."""
+
+        # Catch stdout.
+        buf = StringIO()
+        sys.stdout = buf
+
+        # Execute the normal run method.
+        result = TextTestRunner.run(self, test)
+
+        # 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()
+
+        # Return the results object.
+        return result

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=4326&r1=4325&r2=4326&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 17:33:45 2008
@@ -62,10 +62,6 @@
 from optparse import OptionParser
 from textwrap import dedent
 from copy import copy
-try:
-    from cStringIO import StringIO
-except ImportError:
-    from StringIO import StringIO
 
 
 # constants
@@ -806,25 +802,9 @@
 
         # 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




Related Messages


Powered by MHonArc, Updated Fri Jan 04 17:40:14 2008