Skip to content

Commit d556084

Browse files
committed
Add tests for Version
1 parent 29eb49a commit d556084

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

tests/test_version.py

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import operator
2+
from contextlib import nullcontext as does_not_raise
3+
4+
import pytest
5+
6+
from libtmux._compat import LooseVersion
7+
8+
9+
@pytest.mark.parametrize(
10+
"version",
11+
[
12+
'1',
13+
'1.0',
14+
'1.0.0',
15+
'1.0.0b',
16+
'1.0.0b1',
17+
'1.0.0b-openbsd',
18+
'1.0.0-next',
19+
'1.0.0-next.1',
20+
],
21+
)
22+
def test_version(version):
23+
assert LooseVersion(version)
24+
25+
26+
@pytest.mark.parametrize(
27+
"version,op,versionb,raises",
28+
[
29+
['1', operator.eq, '1', False],
30+
['1', operator.eq, '1.0', False],
31+
['1', operator.eq, '1.0.0', False],
32+
['1', operator.gt, '1.0.0a', False],
33+
['1', operator.gt, '1.0.0b', False],
34+
['1', operator.lt, '1.0.0p1', False],
35+
['1', operator.lt, '1.0.0-openbsd', False],
36+
['1', operator.lt, '1', AssertionError],
37+
['1', operator.lt, '1', AssertionError],
38+
],
39+
)
40+
def test_version_compare(version, op, versionb, raises):
41+
raises_ctx = pytest.raises(raises) if raises else does_not_raise()
42+
with raises_ctx:
43+
assert op(LooseVersion(version), LooseVersion(versionb))

0 commit comments

Comments
 (0)