[PATCH 5/6] wvpytest: add fail_value argument to wvpass and wvpasseq

0 views
Skip to first unread message

Rob Browning

unread,
Jul 1, 2022, 3:22:21 PM7/1/22
to bup-...@googlegroups.com
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 <r...@defaultvalue.org>
Tested-by: Rob Browning <r...@defaultvalue.org>
---

Pushed.

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 523a3de5..63eaa34f 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.30.2

Reply all
Reply to author
Forward
0 new messages