- Notifications
You must be signed in to change notification settings - Fork 329
Open
Description
-
HTMLTestRunner for Version 0.8.3 has a Bug, follow code:
TestResult = unittest.TestResult class _TestResult(TestResult): # note: _TestResult is a pure representation of results. # It lacks the output and reporting ability compares to unittest._TextTestResult. def __init__(self, verbosity=1): TestResult.__init__(self) '''this line start''' self.outputBuffer = StringIO.StringIO() '''this line end''' self.stdout0 = None self.stderr0 = None self.success_count = 0 self.failure_count = 0 self.error_count = 0 self.verbosity = verbosity # result is a list of result in 4 tuple # ( # result code (0: success; 1: fail; 2: error), # TestCase object, # Test output (byte string), # stack trace, # ) self.result = [] def startTest(self, test): TestResult.startTest(self, test) # just one buffer for both stdout and stderr stdout_redirector.fp = self.outputBuffer stderr_redirector.fp = self.outputBuffer self.stdout0 = sys.stdout self.stderr0 = sys.stderr sys.stdout = stdout_redirector sys.stderr = stderr_redirector
this block code will create a
report.htmlafter testsuite end, but in the report.html'spopup_windowwill rewrite outputbuffer. example:
-
Modify this bug, follow me
move code
self.outputBuffer = StringIO.StringIO()todef startTest(self, test): TestResult.startTest(self, test) # just one buffer for both stdout and stderr '''after modify start''' self.outputBuffer = StringIO.StringIO() '''after modify end''' stdout_redirector.fp = self.outputBuffer stderr_redirector.fp = self.outputBuffer self.stdout0 = sys.stdout self.stderr0 = sys.stderr sys.stdout = stdout_redirector sys.stderr = stderr_redirector
Metadata
Metadata
Assignees
Labels
No labels
