]> arthur.ath.cx Git - bup.git/blob - test/lib/wvpytest.py
wvpytest: add fail_value argument to wvpass and wvpasseq
[bup.git] / test / lib / wvpytest.py
1 import pytest
2
3 def WVPASS(cond = True, fail_value=None):
4     if fail_value:
5         assert cond, fail_value
6     else:
7         assert cond
8
9 def WVFAIL(cond = True):
10     assert not cond
11
12 def WVPASSEQ(a, b, fail_value=None):
13     if fail_value:
14         assert a == b, fail_value
15     else:
16         assert a == b
17
18 def WVPASSNE(a, b):
19     assert a != b
20
21 def WVPASSLT(a, b):
22     assert a < b
23
24 def WVPASSLE(a, b):
25     assert a <= b
26
27 def WVPASSGT(a, b):
28     assert a > b
29
30 def WVPASSGE(a, b):
31     assert a >= b
32
33 def WVEXCEPT(etype, func, *args, **kwargs):
34     with pytest.raises(etype):
35         func(*args, **kwargs)
36
37 def WVCHECK(cond, msg):
38     assert cond, msg
39
40 def WVMSG(msg):
41     print(msg)
42
43 wvpass = WVPASS
44 wvfail = WVFAIL
45 wvpasseq = WVPASSEQ
46 wvpassne = WVPASSNE
47 wvpaslt = WVPASSLT
48 wvpassle = WVPASSLE
49 wvpassgt = WVPASSGT
50 wvpassge = WVPASSGE
51 wvexcept = WVEXCEPT
52 wvcheck = WVCHECK
53 wvmsg = WVMSG
54 wvstart = WVMSG