aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2011-08-06 16:14:26 +0200
committerMichał Górny <mgorny@gentoo.org>2011-08-06 16:14:26 +0200
commit79af36f94cc8096e81026536c204a99faca57dcb (patch)
treebd7b283acc7bf0bdc61be9907ca9e642c0b0d9cb
parentSupport undefined in CLI output backend too. (diff)
downloadpms-test-suite-79af36f94cc8096e81026536c204a99faca57dcb.tar.gz
pms-test-suite-79af36f94cc8096e81026536c204a99faca57dcb.tar.bz2
pms-test-suite-79af36f94cc8096e81026536c204a99faca57dcb.zip
Support passing 'undefined' to assertions.
-rw-r--r--pmstestsuite/library/case.py40
1 files changed, 28 insertions, 12 deletions
diff --git a/pmstestsuite/library/case.py b/pmstestsuite/library/case.py
index 55dfa43..4502571 100644
--- a/pmstestsuite/library/case.py
+++ b/pmstestsuite/library/case.py
@@ -212,7 +212,7 @@ class TestCase(ABCObject):
if not a.undefined and not a:
raise AssertionError(str(a))
- def assertTrue(self, cond, msg):
+ def assertTrue(self, cond, msg, undefined = False):
"""
Assert that the condition evaluates to True.
@@ -220,10 +220,12 @@ class TestCase(ABCObject):
@type cond: bool
@param msg: assertion description
@type msg: string
+ @param undefined: whether the result is undefined
+ @type undefined: bool
"""
- self.assertBool(True, cond, msg)
+ self.assertBool(True, cond, msg, undefined)
- def assertFalse(self, cond, msg):
+ def assertFalse(self, cond, msg, undefined = False):
"""
Assert that the condition evaluates to False.
@@ -231,10 +233,12 @@ class TestCase(ABCObject):
@type cond: bool
@param msg: assertion description
@type msg: string
+ @param undefined: whether the result is undefined
+ @type undefined: bool
"""
- self.assertBool(False, cond, msg)
+ self.assertBool(False, cond, msg, undefined)
- def assertBool(self, expect, cond, msg):
+ def assertBool(self, expect, cond, msg, undefined = False):
"""
Assert that the condition evaluates to expected boolean result.
@@ -244,10 +248,13 @@ class TestCase(ABCObject):
@type cond: bool
@param msg: assertion description
@type msg: string
+ @param undefined: whether the result is undefined
+ @type undefined: bool
"""
- self._append_assert(BoolAssertionResult(msg, expect, cond))
+ self._append_assert(BoolAssertionResult(msg, expect, cond),
+ undefined = undefined)
- def assertContains(self, needle, container, msg = None):
+ def assertContains(self, needle, container, msg = None, undefined = False):
"""
Assert the following condition: C{needle in container}.
@@ -257,12 +264,15 @@ class TestCase(ABCObject):
@type container: iterable
@param msg: assertion description or C{None} for default one
@type msg: string/C{None}
+ @param undefined: whether the result is undefined
+ @type undefined: bool
"""
if msg is None:
msg = '%s in %s' % (repr(needle), repr(container))
- self._append_assert(ContainsAssertionResult(msg, needle, container))
+ self._append_assert(ContainsAssertionResult(msg, needle, container),
+ undefined = undefined)
- def assertEqual(self, value, expect, msg):
+ def assertEqual(self, value, expect, msg, undefined = False):
"""
Assert that the value is equal to expected one.
@@ -272,10 +282,13 @@ class TestCase(ABCObject):
@type expect: any
@param msg: assertion description
@type msg: string
+ @param undefined: whether the result is undefined
+ @type undefined: bool
"""
- self._append_assert(EqualAssertionResult(msg, expect, value))
+ self._append_assert(EqualAssertionResult(msg, expect, value),
+ undefined = undefined)
- def assertNotEqual(self, value, unallowed, msg):
+ def assertNotEqual(self, value, unallowed, msg, undefined = False):
"""
Assert that the value is other than an unallowed one.
@@ -285,8 +298,11 @@ class TestCase(ABCObject):
@type expect: any
@param msg: assertion description
@type msg: string
+ @param undefined: whether the result is undefined
+ @type undefined: bool
"""
- self._append_assert(NotEqualAssertionResult(msg, unallowed, value))
+ self._append_assert(NotEqualAssertionResult(msg, unallowed, value),
+ undefined = undefined)
@abstractmethod
def check_result(self, pm):