This is analagous to the second, optional assert argument, although
unlike that one, it is of course always evaluated.
It can allow more informative failures:
wvpasseq(re.split(r'[0-9]+', s), exp,
"re.split(r'[0-9]+', %r) != %r" % (s, exp))
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
import pytest
-def WVPASS(cond = True):
- assert cond
+def WVPASS(cond = True, fail_value=None):
+ if fail_value:
+ assert cond, fail_value
+ else:
+ assert cond
def WVFAIL(cond = True):
assert not cond
-def WVPASSEQ(a, b):
- assert a == b
+def WVPASSEQ(a, b, fail_value=None):
+ if fail_value:
+ assert a == b, fail_value
+ else:
+ assert a == b
def WVPASSNE(a, b):
assert a != b