Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions test/single_line_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# found in the LICENSE file.

import shutil
from unittest import TextTestResult

from color_runner import ColorTextResult, ColorTextRunner

Expand Down Expand Up @@ -67,6 +68,27 @@ def printErrors(self):
self.stream.write('\n')
super().printErrors()

# Override addExpectedFailure and addUnexpectedSuccess since, for some reason
# these methods in TextTestResult do not use `_write_status` like the other ones.
# TODO(sbc): Send a patch to upstream python to sue `_write_status` in TextTestResult.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# TODO(sbc): Send a patch to upstream python to sue `_write_status` in TextTestResult.
# TODO(sbc): Send a patch to upstream python to use `_write_status` in TextTestResult.

def addExpectedFailure(self, test, err):
super(TextTestResult, self).addExpectedFailure(test, err)
if self.showAll:
self._write_status(test, "expected failure")
self.stream.flush()
elif self.dots:
self.stream.write("x")
self.stream.flush()

def addUnexpectedSuccess(self, test):
super(TextTestResult, self).addUnexpectedSuccess(test)
if self.showAll:
self._write_status(test, "unexpected success")
self.stream.flush()
elif self.dots:
self.stream.write("u")
self.stream.flush()


class SingleLineTestRunner(ColorTextRunner):
"""Subclass of TextTestResult that uses SingleLineTestResult"""
Expand Down
Loading