From be00d15d99926e4ea1bfd32ad5b65556d1955893 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Fri, 29 Jan 2016 21:30:11 +0100 Subject: [PATCH] tests: do not crash when trying to log class setup/teardown fail QubesOS/qubes-issues#1691 --- tests/run.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/run.py b/tests/run.py index d4064898..dae4c0b7 100755 --- a/tests/run.py +++ b/tests/run.py @@ -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(