From 14761c09d27934188829e3c804aca6593757ed9b Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Mon, 5 Dec 2011 10:24:37 +0100 Subject: [PATCH] src/linux/integration-test: Do not crash on absent _outcomeForDoCleanups unittest.TestCase unfortunately does not have any public API to check whether a test case succeeded, so we use the private self._outcomeForDoCleanups. This does not seem to exist every time, so avoid a crash if it doesn't. --- src/linux/integration-test | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/linux/integration-test b/src/linux/integration-test index cc2b329..871d5e8 100755 --- a/src/linux/integration-test +++ b/src/linux/integration-test @@ -88,11 +88,18 @@ class Tests(unittest.TestCase): shutil.rmtree(self.sysfs) # on failures, print daemon log - if not self._outcomeForDoCleanups.success: - with open(self.log.name) as f: - sys.stderr.write('\n-------------- daemon log: ----------------\n') - sys.stderr.write(f.read()) - sys.stderr.write('------------------------------\n') + try: + if self._outcomeForDoCleanups.success: + return + except AttributeError: + # _outcomeForDoCleanups is a private member which seems to be a bit + # unreliable; if it does not exist, just ignore it + return + + with open(self.log.name) as f: + sys.stderr.write('\n-------------- daemon log: ----------------\n') + sys.stderr.write(f.read()) + sys.stderr.write('------------------------------\n') # # Methods for fake sysfs