Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make subtest failures appear in unit test reporting #131

Merged
merged 1 commit into from
Aug 5, 2019
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
43 changes: 23 additions & 20 deletions tests/coloredtestrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ def __init__(self, stream, descriptions, verbosity=1):
self.success_count = 0
self.failure_count = 0
self.error_count = 0
self.skip_count = 0
self.verbosity = verbosity

# deny TextTestResult showAll functionality
Expand Down Expand Up @@ -258,12 +259,8 @@ def addSuccess(self, test):
super(ColoredTestResult, self).addSuccess(test)
output = self.complete_output()
self.result.append((0, test, output, ''))
# if self.verbosity > 1:
# sys.stderr.write('ok ')
# sys.stderr.write(str(test))
# sys.stderr.write('\n')
# else:
# pass #sys.stderr.write('.')
sys.stdout.write('.')
sys.stdout.flush()

if not hasattr(self, 'successes'):
self.successes = [test]
Expand All @@ -273,28 +270,34 @@ def addSuccess(self, test):
def addError(self, test, err):
self.error_count += 1
super(ColoredTestResult, self).addError(test, err)
_, _exc_str = self.errors[-1]
output = self.complete_output()
_, _exc_str = self.errors[-1]
self.result.append((2, test, output, _exc_str))
# if self.verbosity > 1:
# sys.stderr.write('E ')
# sys.stderr.write(str(test))
# sys.stderr.write('\n')
# else:
# pass #sys.stderr.write('E')
sys.stdout.write('E')
sys.stdout.flush()

def addFailure(self, test, err):
self.failure_count += 1
super(ColoredTestResult, self).addFailure(test, err)
_, _exc_str = self.failures[-1]
output = self.complete_output()
_, _exc_str = self.failures[-1]
self.result.append((1, test, output, _exc_str))
# if self.verbosity > 1:
# sys.stderr.write('F ')
# sys.stderr.write(str(test))
# sys.stderr.write('\n')
# else:
# pass #sys.stderr.write('F')
sys.stdout.write('F')
sys.stdout.flush()

def addSubTest(self, test, subtest, err):
if err is not None:
if issubclass(err[0], test.failureException):
self.addFailure(subtest, err)
else:
self.addError(subtest, err)

def addSkip(self, test, reason):
self.skip_count += 1
super(ColoredTestResult, self).addSkip(test, reason)
self.complete_output()
sys.stdout.write('s')
sys.stdout.flush()

def get_all_cases_run(self):
'''Return a list of each test case which failed or succeeded
Expand Down