File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44# found in the LICENSE file.
55
66import shutil
7+ from unittest import TextTestResult
78
89from color_runner import ColorTextResult , ColorTextRunner
910
@@ -67,6 +68,27 @@ def printErrors(self):
6768 self .stream .write ('\n ' )
6869 super ().printErrors ()
6970
71+ # Override addExpectedFailure and addUnexpectedSuccess since, for some reason
72+ # these methods in TextTestResult do not use `_write_status` like the other ones.
73+ # TODO(sbc): Send a patch to upstream python to sue `_write_status` in TextTestResult.
74+ def addExpectedFailure (self , test , err ):
75+ super (TextTestResult , self ).addExpectedFailure (test , err )
76+ if self .showAll :
77+ self ._write_status (test , "expected failure" )
78+ self .stream .flush ()
79+ elif self .dots :
80+ self .stream .write ("x" )
81+ self .stream .flush ()
82+
83+ def addUnexpectedSuccess (self , test ):
84+ super (TextTestResult , self ).addUnexpectedSuccess (test )
85+ if self .showAll :
86+ self ._write_status (test , "unexpected success" )
87+ self .stream .flush ()
88+ elif self .dots :
89+ self .stream .write ("u" )
90+ self .stream .flush ()
91+
7092
7193class SingleLineTestRunner (ColorTextRunner ):
7294 """Subclass of TextTestResult that uses SingleLineTestResult"""
You can’t perform that action at this time.
0 commit comments