|
13 | 13 |
|
14 | 14 | import pytest
|
15 | 15 |
|
16 |
| -from domdf_python_tools.utils import str2tuple, tuple2str, chunks, list2str, list2string, bdict |
| 16 | +from domdf_python_tools.utils import str2tuple, tuple2str, chunks, list2str, list2string, bdict, pyversion |
17 | 17 | from domdf_python_tools import utils
|
18 | 18 |
|
19 | 19 |
|
| 20 | +def test_pyversion(): |
| 21 | + assert isinstance(pyversion, int) |
| 22 | + |
| 23 | + |
20 | 24 | def test_str2tuple():
|
21 | 25 | assert isinstance(str2tuple("1,2,3"), tuple) # tests without spaces
|
22 | 26 | assert isinstance(str2tuple("1, 2, 3"), tuple) # tests with spaces
|
23 | 27 | assert isinstance(str2tuple("1; 2; 3", sep=";"), tuple) # tests with semicolon
|
24 |
| - if str2tuple("1,2,3") == (1, 2, 3): |
25 |
| - assert 1 |
26 |
| - else: |
27 |
| - assert 0 |
| 28 | + assert str2tuple("1,2,3") == (1, 2, 3) |
28 | 29 |
|
29 | 30 |
|
30 | 31 | def test_tuple2str():
|
31 | 32 | assert isinstance(tuple2str(("1", "2", "3",)), str)
|
32 |
| - if tuple2str((1, 2, 3)) == "1,2,3": |
33 |
| - assert 1 |
34 |
| - else: |
35 |
| - assert 0 |
| 33 | + assert tuple2str((1, 2, 3)) == "1,2,3" |
36 | 34 |
|
37 | 35 | assert isinstance(tuple2str((1, 2, 3,), sep=";"), str) # tests with semicolon
|
38 |
| - if tuple2str((1, 2, 3), sep=";") == "1;2;3": |
39 |
| - assert 1 |
40 |
| - else: |
41 |
| - assert 0 |
| 36 | + assert tuple2str((1, 2, 3), sep=";") == "1;2;3" |
42 | 37 |
|
43 | 38 |
|
44 | 39 | def test_chunks():
|
45 | 40 | assert isinstance(chunks(list(range(100)), 5), types.GeneratorType)
|
46 |
| - if list(chunks(list(range(100)), 5))[0] == [0, 1, 2, 3, 4]: |
47 |
| - assert 1 |
48 |
| - else: |
49 |
| - assert 0 |
| 41 | + assert list(chunks(list(range(100)), 5))[0] == [0, 1, 2, 3, 4] |
50 | 42 |
|
51 | 43 |
|
52 | 44 | def test_list2str():
|
53 | 45 | assert isinstance(list2str([1, 2, 3, ]), str)
|
54 |
| - if list2str([1, 2, 3]) == "1,2,3": |
55 |
| - assert 1 |
56 |
| - else: |
57 |
| - assert 0 |
| 46 | + assert list2str([1, 2, 3]) == "1,2,3" |
58 | 47 |
|
59 | 48 | assert isinstance(list2str([1, 2, 3], sep=";"), str) # tests with semicolon
|
60 |
| - if list2str((1, 2, 3), sep=";") == "1;2;3": |
61 |
| - assert 1 |
62 |
| - else: |
63 |
| - assert 0 |
| 49 | + assert list2str((1, 2, 3), sep=";") == "1;2;3" |
64 | 50 |
|
65 | 51 | assert isinstance(list2string([1, 2, 3, ]), str)
|
66 |
| - if list2string([1, 2, 3]) == "1,2,3": |
67 |
| - assert 1 |
68 |
| - else: |
69 |
| - assert 0 |
| 52 | + assert list2string([1, 2, 3]) == "1,2,3" |
70 | 53 |
|
71 | 54 | assert isinstance(list2string([1, 2, 3], sep=";"), str) # tests with semicolon
|
72 |
| - if list2string((1, 2, 3), sep=";") == "1;2;3": |
73 |
| - assert 1 |
74 |
| - else: |
75 |
| - assert 0 |
| 55 | + assert list2string((1, 2, 3), sep=";") == "1;2;3" |
76 | 56 |
|
77 | 57 |
|
78 | 58 | def test_bdict():
|
@@ -110,13 +90,13 @@ def test_bdict_booleans():
|
110 | 90 | new_dict = bdict(original_dict)
|
111 | 91 |
|
112 | 92 | assert new_dict[True] == "True"
|
113 |
| - assert new_dict["True"] == True |
| 93 | + assert new_dict["True"] |
114 | 94 |
|
115 | 95 | original_dict = {True: True, False: False, None: None}
|
116 | 96 |
|
117 | 97 | new_dict = bdict(original_dict)
|
118 | 98 |
|
119 |
| - assert new_dict[True] is True |
| 99 | + assert new_dict[True] |
120 | 100 |
|
121 | 101 |
|
122 | 102 | def test_bdict_from_zip():
|
@@ -231,4 +211,3 @@ def test_permutations():
|
231 | 211 |
|
232 | 212 | with pytest.raises(ValueError):
|
233 | 213 | utils.permutations(data, 0)
|
234 |
| - |
0 commit comments