tests: do not crash when trying to log class setup/teardown fail

QubesOS/qubes-issues#1691
This commit is contained in:
Marek Marczykowski-Górecki 2016-01-29 21:30:11 +01:00
parent 84af7386f5
commit be00d15d99
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -133,7 +133,11 @@ class QubesTestResult(unittest.TestResult):
def addError(self, test, err): # pylint: disable=invalid-name
super(QubesTestResult, self).addError(test, err)
test.log.critical('ERROR ({err[0].__name__}: {err[1]!r})'.format(err=err))
try:
test.log.critical(
'ERROR ({err[0].__name__}: {err[1]!r})'.format(err=err))
except AttributeError:
pass
if self.showAll:
self.stream.writeln(
'{color[red]}{color[bold]}ERROR{color[normal]} ({})'.format(
@ -157,7 +161,10 @@ class QubesTestResult(unittest.TestResult):
def addSkip(self, test, reason): # pylint: disable=invalid-name
super(QubesTestResult, self).addSkip(test, reason)
test.log.warning('skipped ({})'.format(reason))
try:
test.log.warning('skipped ({})'.format(reason))
except AttributeError:
pass
if self.showAll:
self.stream.writeln(
'{color[cyan]}skipped{color[normal]} ({})'.format(