|
10 | 10 |
|
11 | 11 |
|
12 | 12 | class TestBit: |
13 | | - def test_list(self): |
| 13 | + def test_list(self) -> None: |
14 | 14 | assert Bit([True, False, True]).to_list() == [True, False, True] |
15 | 15 |
|
16 | | - def test_list_none(self): |
| 16 | + def test_list_none(self) -> None: |
17 | 17 | with pytest.raises(ValueError) as error: |
18 | 18 | Bit([True, None, True]) # type: ignore |
19 | 19 | assert str(error.value) == 'expected list[bool]' |
20 | 20 |
|
21 | | - def test_list_int(self): |
| 21 | + def test_list_int(self) -> None: |
22 | 22 | with pytest.raises(ValueError) as error: |
23 | 23 | Bit([254, 7, 0]) # type: ignore |
24 | 24 | assert str(error.value) == 'expected list[bool]' |
25 | 25 |
|
26 | | - def test_list_list(self): |
| 26 | + def test_list_list(self) -> None: |
27 | 27 | with pytest.raises(ValueError) as error: |
28 | 28 | Bit([[True, False], [True, False]]) # type: ignore |
29 | 29 | assert str(error.value) == 'expected list[bool]' |
30 | 30 |
|
31 | | - def test_str(self): |
| 31 | + def test_str(self) -> None: |
32 | 32 | assert Bit('101').to_list() == [True, False, True] |
33 | 33 |
|
34 | | - def test_str_two(self): |
| 34 | + def test_str_two(self) -> None: |
35 | 35 | with pytest.raises(ValueError) as error: |
36 | 36 | Bit('201') |
37 | 37 | assert str(error.value) == 'expected bit string' |
38 | 38 |
|
39 | | - def test_bytes(self): |
| 39 | + def test_bytes(self) -> None: |
40 | 40 | assert Bit(b'\xff\x00\xf0').to_text() == '111111110000000011110000' |
41 | 41 | assert Bit(b'\xfe\x07\x00').to_text() == '111111100000011100000000' |
42 | 42 |
|
43 | 43 | @pytest.mark.skipif(not NUMPY_AVAILABLE, reason='NumPy required') |
44 | | - def test_ndarray(self): |
| 44 | + def test_ndarray(self) -> None: |
45 | 45 | arr = np.array([True, False, True]) |
46 | 46 | assert Bit(arr).to_list() == [True, False, True] |
47 | 47 | assert np.array_equal(Bit(arr).to_numpy(), arr) |
48 | 48 |
|
49 | 49 | @pytest.mark.skipif(not NUMPY_AVAILABLE, reason='NumPy required') |
50 | | - def test_ndarray_unpackbits(self): |
| 50 | + def test_ndarray_unpackbits(self) -> None: |
51 | 51 | arr = np.unpackbits(np.array([254, 7, 0], dtype=np.uint8)) |
52 | 52 | assert Bit(arr).to_text() == '111111100000011100000000' |
53 | 53 |
|
54 | 54 | @pytest.mark.skipif(not NUMPY_AVAILABLE, reason='NumPy required') |
55 | | - def test_ndarray_uint8(self): |
| 55 | + def test_ndarray_uint8(self) -> None: |
56 | 56 | arr = np.array([254, 7, 0], dtype=np.uint8) |
57 | 57 | with pytest.raises(ValueError) as error: |
58 | 58 | Bit(arr) |
59 | 59 | assert str(error.value) == 'expected elements to be boolean' |
60 | 60 |
|
61 | 61 | @pytest.mark.skipif(not NUMPY_AVAILABLE, reason='NumPy required') |
62 | | - def test_ndarray_uint16(self): |
| 62 | + def test_ndarray_uint16(self) -> None: |
63 | 63 | arr = np.array([254, 7, 0], dtype=np.uint16) |
64 | 64 | with pytest.raises(ValueError) as error: |
65 | 65 | Bit(arr) # type: ignore |
66 | 66 | assert str(error.value) == 'expected elements to be boolean' |
67 | 67 |
|
68 | | - def test_bool(self): |
| 68 | + def test_bool(self) -> None: |
69 | 69 | with pytest.raises(ValueError) as error: |
70 | 70 | Bit(True) # type: ignore |
71 | 71 | assert str(error.value) == 'expected bytes, str, list, or ndarray' |
72 | 72 |
|
73 | | - def test_random(self): |
| 73 | + def test_random(self) -> None: |
74 | 74 | value = ''.join(random.choices(['0', '1'], k=random.randint(1024, 2048))) |
75 | 75 | assert Bit(value).to_text() == value |
76 | 76 |
|
77 | | - def test_repr(self): |
| 77 | + def test_repr(self) -> None: |
78 | 78 | assert repr(Bit([True, False, True])) == 'Bit(101)' |
79 | 79 | assert str(Bit([True, False, True])) == 'Bit(101)' |
80 | 80 |
|
81 | | - def test_equality(self): |
| 81 | + def test_equality(self) -> None: |
82 | 82 | assert Bit([True, False, True]) == Bit([True, False, True]) |
83 | 83 | assert Bit([True, False, True]) != Bit([True, False, False]) |
0 commit comments