mirror of
https://github.com/python/cpython.git
synced 2025-08-28 20:56:54 +00:00
bpo-13236: Flush the output stream more often in unittest (GH-29864)
It can prevent some losses when output to buffered stream.
This commit is contained in:
parent
87a18deda4
commit
f42a06ba27
4 changed files with 54 additions and 5 deletions
|
@ -68,6 +68,7 @@ class TextTestResult(result.TestResult):
|
|||
self.stream.write(self.getDescription(test))
|
||||
self.stream.write(" ... ")
|
||||
self.stream.writeln(status)
|
||||
self.stream.flush()
|
||||
self._newline = True
|
||||
|
||||
def addSubTest(self, test, subtest, err):
|
||||
|
@ -121,6 +122,7 @@ class TextTestResult(result.TestResult):
|
|||
super(TextTestResult, self).addExpectedFailure(test, err)
|
||||
if self.showAll:
|
||||
self.stream.writeln("expected failure")
|
||||
self.stream.flush()
|
||||
elif self.dots:
|
||||
self.stream.write("x")
|
||||
self.stream.flush()
|
||||
|
@ -129,6 +131,7 @@ class TextTestResult(result.TestResult):
|
|||
super(TextTestResult, self).addUnexpectedSuccess(test)
|
||||
if self.showAll:
|
||||
self.stream.writeln("unexpected success")
|
||||
self.stream.flush()
|
||||
elif self.dots:
|
||||
self.stream.write("u")
|
||||
self.stream.flush()
|
||||
|
@ -136,6 +139,7 @@ class TextTestResult(result.TestResult):
|
|||
def printErrors(self):
|
||||
if self.dots or self.showAll:
|
||||
self.stream.writeln()
|
||||
self.stream.flush()
|
||||
self.printErrorList('ERROR', self.errors)
|
||||
self.printErrorList('FAIL', self.failures)
|
||||
|
||||
|
@ -145,6 +149,7 @@ class TextTestResult(result.TestResult):
|
|||
self.stream.writeln("%s: %s" % (flavour,self.getDescription(test)))
|
||||
self.stream.writeln(self.separator2)
|
||||
self.stream.writeln("%s" % err)
|
||||
self.stream.flush()
|
||||
|
||||
|
||||
class TextTestRunner(object):
|
||||
|
@ -239,4 +244,5 @@ class TextTestRunner(object):
|
|||
self.stream.writeln(" (%s)" % (", ".join(infos),))
|
||||
else:
|
||||
self.stream.write("\n")
|
||||
self.stream.flush()
|
||||
return result
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue