From d163393f491ad8ffb20336eadec46b3688b6951a Mon Sep 17 00:00:00 2001 From: Rob Browning Date: Tue, 28 Jun 2022 16:37:00 -0500 Subject: [PATCH] wvpytest: add fail_value argument to wvpass and wvpasseq 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 Tested-by: Rob Browning --- test/lib/wvpytest.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/test/lib/wvpytest.py b/test/lib/wvpytest.py index 523a3de..63eaa34 100644 --- a/test/lib/wvpytest.py +++ b/test/lib/wvpytest.py @@ -1,13 +1,19 @@ 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 -- 2.39.2