@@ -8,14 +8,12 @@ def test_list(self):
8
8
assert Bit ([True , False , True ]).to_list () == [True , False , True ]
9
9
10
10
def test_list_none (self ):
11
- with pytest .raises (ValueError ) as error :
12
- Bit ([True , None , True ])
13
- assert str (error .value ) == 'expected all elements to be boolean'
11
+ with pytest .warns (UserWarning , match = 'expected elements to be boolean' ):
12
+ assert Bit ([True , None , True ]).to_text () == '101'
14
13
15
14
def test_list_int (self ):
16
- with pytest .raises (ValueError ) as error :
17
- Bit ([254 , 7 , 0 ])
18
- assert str (error .value ) == 'expected all elements to be boolean'
15
+ with pytest .warns (UserWarning , match = 'expected elements to be boolean' ):
16
+ assert Bit ([254 , 7 , 0 ]).to_text () == '110'
19
17
20
18
def test_tuple (self ):
21
19
assert Bit ((True , False , True )).to_list () == [True , False , True ]
@@ -29,13 +27,13 @@ def test_bytes(self):
29
27
30
28
def test_ndarray_uint8 (self ):
31
29
arr = np .array ([254 , 7 , 0 ], dtype = np .uint8 )
32
- assert Bit (arr ).to_text () == '111111100000011100000000'
30
+ with pytest .warns (UserWarning , match = 'expected elements to be boolean' ):
31
+ assert Bit (arr ).to_text () == '110'
33
32
34
33
def test_ndarray_uint16 (self ):
35
34
arr = np .array ([254 , 7 , 0 ], dtype = np .uint16 )
36
- with pytest .raises (ValueError ) as error :
37
- Bit (arr )
38
- assert str (error .value ) == 'expected dtype to be bool or uint8'
35
+ with pytest .warns (UserWarning , match = 'expected elements to be boolean' ):
36
+ assert Bit (arr ).to_text () == '110'
39
37
40
38
def test_ndarray_same_object (self ):
41
39
arr = np .array ([True , False , True ])
0 commit comments