|
8 | 8 |
|
9 | 9 |
|
10 | 10 | class TestBit: |
11 | | - @pytest.mark.skipif(np is None, reason='NumPy required') |
12 | 11 | def test_list(self): |
13 | 12 | assert Bit([True, False, True]).to_list() == [True, False, True] |
14 | 13 |
|
15 | | - @pytest.mark.skipif(np is None, reason='NumPy required') |
16 | 14 | def test_list_none(self): |
17 | | - with pytest.warns(UserWarning, match='expected elements to be boolean'): |
18 | | - assert Bit([True, None, True]).to_text() == '101' # ty: ignore[invalid-argument-type] |
| 15 | + with pytest.raises(ValueError) as error: |
| 16 | + Bit([True, None, True]) # ty: ignore[invalid-argument-type] |
| 17 | + assert str(error.value) == 'expected list[bool]' |
19 | 18 |
|
20 | | - @pytest.mark.skipif(np is None, reason='NumPy required') |
21 | 19 | def test_list_int(self): |
22 | | - with pytest.warns(UserWarning, match='expected elements to be boolean'): |
23 | | - assert Bit([254, 7, 0]).to_text() == '110' # ty: ignore[invalid-argument-type] |
| 20 | + with pytest.raises(ValueError) as error: |
| 21 | + Bit([254, 7, 0]) # ty: ignore[invalid-argument-type] |
| 22 | + assert str(error.value) == 'expected list[bool]' |
24 | 23 |
|
25 | | - @pytest.mark.skipif(np is None, reason='NumPy required') |
26 | 24 | def test_str(self): |
27 | 25 | assert Bit('101').to_list() == [True, False, True] |
28 | 26 |
|
| 27 | + def test_str_two(self): |
| 28 | + with pytest.raises(ValueError) as error: |
| 29 | + Bit('201') |
| 30 | + assert str(error.value) == 'expected bit string' |
| 31 | + |
29 | 32 | def test_bytes(self): |
30 | 33 | assert Bit(b'\xff\x00\xf0').to_text() == '111111110000000011110000' |
31 | 34 | assert Bit(b'\xfe\x07\x00').to_text() == '111111100000011100000000' |
@@ -53,24 +56,20 @@ def test_ndarray_uint16(self): |
53 | 56 | with pytest.warns(UserWarning, match='expected elements to be boolean'): |
54 | 57 | assert Bit(arr).to_text() == '110' |
55 | 58 |
|
56 | | - @pytest.mark.skipif(np is None, reason='NumPy required') |
57 | 59 | def test_ndim_two(self): |
58 | 60 | with pytest.raises(ValueError) as error: |
59 | 61 | Bit([[True, False], [True, False]]) # ty: ignore[invalid-argument-type] |
60 | | - assert str(error.value) == 'expected ndim to be 1' |
| 62 | + assert str(error.value) == 'expected list[bool]' |
61 | 63 |
|
62 | | - @pytest.mark.skipif(np is None, reason='NumPy required') |
63 | 64 | def test_ndim_zero(self): |
64 | 65 | with pytest.raises(ValueError) as error: |
65 | 66 | Bit(True) # ty: ignore[invalid-argument-type] |
66 | | - assert str(error.value) == 'expected ndim to be 1' |
| 67 | + assert str(error.value) == 'expected bytes, str, list, or ndarray' |
67 | 68 |
|
68 | | - @pytest.mark.skipif(np is None, reason='NumPy required') |
69 | 69 | def test_repr(self): |
70 | 70 | assert repr(Bit([True, False, True])) == 'Bit(101)' |
71 | 71 | assert str(Bit([True, False, True])) == 'Bit(101)' |
72 | 72 |
|
73 | | - @pytest.mark.skipif(np is None, reason='NumPy required') |
74 | 73 | def test_equality(self): |
75 | 74 | assert Bit([True, False, True]) == Bit([True, False, True]) |
76 | 75 | assert Bit([True, False, True]) != Bit([True, False, False]) |
0 commit comments