diff options
author | Martin Pitt <martin.pitt@ubuntu.com> | 2011-12-05 10:24:37 +0100 |
---|---|---|
committer | Martin Pitt <martin.pitt@ubuntu.com> | 2011-12-05 10:24:37 +0100 |
commit | 14761c09d27934188829e3c804aca6593757ed9b (patch) | |
tree | 75728811ededaed507c07a45b095b40e95c61b04 | |
parent | 88c6d141ef6b09827d026e49ca3c562e64e10bee (diff) |
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.
-rwxr-xr-x | src/linux/integration-test | 17 |
1 files 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 |