aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2011-08-07 16:48:44 +0200
committerMichał Górny <mgorny@gentoo.org>2011-08-07 16:48:44 +0200
commit320871c9bef49c07de7a6701f12000a08cd10132 (patch)
tree1b2c87a9543c87c44de475120cfbd0b27be54521 /pmstestsuite
parentFix random.choice() failure. (diff)
downloadpms-test-suite-320871c9bef49c07de7a6701f12000a08cd10132.tar.gz
pms-test-suite-320871c9bef49c07de7a6701f12000a08cd10132.tar.bz2
pms-test-suite-320871c9bef49c07de7a6701f12000a08cd10132.zip
Improve banned command tests not to show output when irrelevant.
If the test didn't pass any output and it was completely expected, there's no reason to show undefined '?'.
Diffstat (limited to 'pmstestsuite')
-rw-r--r--pmstestsuite/library/standard/banned_commands.py56
1 files changed, 36 insertions, 20 deletions
diff --git a/pmstestsuite/library/standard/banned_commands.py b/pmstestsuite/library/standard/banned_commands.py
index 4438f12..b261f43 100644
--- a/pmstestsuite/library/standard/banned_commands.py
+++ b/pmstestsuite/library/standard/banned_commands.py
@@ -30,16 +30,24 @@ class DoHardCommandTest(BannedCommandTest):
def check_dbus_result(self, output, pm):
try:
BannedCommandTest.check_dbus_result(self, output, pm)
- finally:
- try:
- res = True if output[0] == '0' else False
- except IndexError:
- res = None
- if self.eapi < 4:
- self.assertTrue(res, 'hardlink created')
- else:
- self.assertFalse(res, 'hardlink created',
- undefined = True)
+ except AssertionError as e:
+ exc = e
+ else:
+ exc = None
+
+ try:
+ res = True if output[0] == '0' else False
+ except IndexError:
+ res = None
+
+ if self.eapi < 4:
+ self.assertTrue(res, 'hardlink created')
+ elif res is not None or exc:
+ self.assertFalse(res, 'hardlink created',
+ undefined = True)
+
+ if exc:
+ raise exc
class DoSedCommandTest(BannedCommandTest):
""" Test whether dosed command is actually banned. """
@@ -53,13 +61,21 @@ class DoSedCommandTest(BannedCommandTest):
def check_dbus_result(self, output, pm):
try:
BannedCommandTest.check_dbus_result(self, output, pm)
- finally:
- try:
- res = output[0].strip()
- except IndexError:
- res = None
- if self.eapi < 4:
- self.assertEqual(res, 'SED WORKED', 'dosed result')
- else:
- self.assertNotEqual(res, 'SED WORKED', 'dosed result',
- undefined = True)
+ except AssertionError as e:
+ exc = e
+ else:
+ exc = None
+
+ try:
+ res = output[0].strip()
+ except IndexError:
+ res = None
+
+ if self.eapi < 4:
+ self.assertEqual(res, 'SED WORKED', 'dosed result')
+ elif res is not None or exc:
+ self.assertNotEqual(res, 'SED WORKED', 'dosed result',
+ undefined = True)
+
+ if exc:
+ raise exc