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.
This commit is contained in:
Martin Pitt 2011-12-05 10:24:37 +01:00
parent 88c6d141ef
commit 14761c09d2

View file

@ -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