55
66
77def _test_invariance_basic (
8- f_read : callable , f_write : callable , endianness : bytes ,
9- basic_type : bytes , data : bytes , value : any ) -> None :
8+ f_read : callable , f_write : callable , endianness : str , basic_type : str ,
9+ data : bytes , value : any ) -> None :
1010 stream = BytesIO (data )
1111 value_ = f_read (stream , endianness , basic_type )
1212 assert value_ == value
@@ -17,7 +17,7 @@ def _test_invariance_basic(
1717
1818
1919def _test_invariance (
20- f_read : callable , f_write : callable , endianness : bytes , size_t : bytes ,
20+ f_read : callable , f_write : callable , endianness : str , size_t : str ,
2121 obj_def : any , data : bytes , obj : any ) -> None :
2222 stream = BytesIO (data )
2323 obj_ = f_read (stream , endianness , size_t , obj_def )
@@ -29,13 +29,13 @@ def _test_invariance(
2929
3030
3131def test_cast () -> None :
32- assert cast (b '?' ) == bool
33- assert cast (b 'c' ) == bytes
34- assert cast (b 's' ) == bytes
35- assert cast (b 'f' ) == float
36- assert cast (b 'd' ) == float
37- assert cast (b 'h' ) == int
38- assert cast (b 'i' ) == int
32+ assert cast ('?' ) == bool
33+ assert cast ('c' ) == bytes
34+ assert cast ('s' ) == bytes
35+ assert cast ('f' ) == float
36+ assert cast ('d' ) == float
37+ assert cast ('h' ) == int
38+ assert cast ('i' ) == int
3939
4040
4141def test_read_bytes_until () -> None :
@@ -46,65 +46,65 @@ def test_read_bytes_until() -> None:
4646
4747def test_basic_string () -> None :
4848 _test_invariance_basic (
49- _read_basic , _write_basic , b '<' , b 's' , b'abcdef\0 ' , b'abcdef' )
49+ _read_basic , _write_basic , '<' , 's' , b'abcdef\0 ' , b'abcdef' )
5050
5151
5252def test_basic_int_le () -> None :
5353 _test_invariance_basic (
54- _read_basic , _write_basic , b '<' , b 'i' , b'\2 \0 \0 \0 ' , 2 )
54+ _read_basic , _write_basic , '<' , 'i' , b'\2 \0 \0 \0 ' , 2 )
5555
5656
5757def test_basic_int_be () -> None :
5858 _test_invariance_basic (
59- _read_basic , _write_basic , b '>' , b 'i' , b'\0 \0 \0 \2 ' , 2 )
59+ _read_basic , _write_basic , '>' , 'i' , b'\0 \0 \0 \2 ' , 2 )
6060
6161
6262def test_list_char () -> None :
6363 _test_invariance (
64- read , write , b '<' , b 'h' , [b 'c' ], b'\3 \0 a\0 c' , [b'a' , b'\0 ' , b'c' ])
64+ read , write , '<' , 'h' , ['c' ], b'\3 \0 a\0 c' , [b'a' , b'\0 ' , b'c' ])
6565
6666
6767def test_list_nibble () -> None :
6868 _test_invariance (
69- read , write , b '<' , b 'h' , [b 'h' ], b'\3 \0 \1 \0 \2 \0 \3 \0 ' , [1 , 2 , 3 ])
69+ read , write , '<' , 'h' , ['h' ], b'\3 \0 \1 \0 \2 \0 \3 \0 ' , [1 , 2 , 3 ])
7070
7171
7272def test_list_list () -> None :
7373 _test_invariance (
74- read , write , b '<' , b 'h' , [[b 'b' ]], b'\2 \0 \2 \0 \0 \1 \2 \0 \2 \3 ' ,
74+ read , write , '<' , 'h' , [['b' ]], b'\2 \0 \2 \0 \0 \1 \2 \0 \2 \3 ' ,
7575 [[0 , 1 ], [2 , 3 ]])
7676
7777
7878def test_object_char_int () -> None :
7979 _test_invariance (
80- read , write , b '<' , b 'h' , (b 'c' , b 'i' ), b'a\3 \0 \0 \0 ' , (b'a' , 3 ))
80+ read , write , '<' , 'h' , ('c' , 'i' ), b'a\3 \0 \0 \0 ' , (b'a' , 3 ))
8181
8282
8383def test_object_nibble_string_char () -> None :
8484 _test_invariance (
85- read , write , b '<' , b 'h' , (b 'h' , b 's' , b 'c' ), b'\2 \0 abcdef\0 x' ,
85+ read , write , '<' , 'h' , ('h' , 's' , 'c' ), b'\2 \0 abcdef\0 x' ,
8686 (2 , b'abcdef' , b'x' ))
8787
8888
8989def test_object_object () -> None :
9090 _test_invariance (
91- read , write , b '<' , b 'h' , (((b 'c' , ), ), (b 'c' , ), ), b'ab' ,
91+ read , write , '<' , 'h' , ((('c' , ), ), ('c' , ), ), b'ab' ,
9292 (((b'a' , ), ), (b'b' , )))
9393
9494
9595def test_list_tuple () -> None :
9696 _test_invariance (
97- read , write , b '<' , b 'h' , [b 'c' , b 'c' , b 'c' ], b'\2 \0 abcabc' ,
97+ read , write , '<' , 'h' , ['c' , 'c' , 'c' ], b'\2 \0 abcabc' ,
9898 [b'a' , b'b' , b'c' , b'a' , b'b' , b'c' ])
9999
100100
101101def test_list_object () -> None :
102102 _test_invariance (
103- read , write , b '<' , b 'h' , [(b 'c' , b 'c' , b 'c' )], b'\2 \0 abcabc' ,
103+ read , write , '<' , 'h' , [('c' , 'c' , 'c' )], b'\2 \0 abcabc' ,
104104 [(b'a' , b'b' , b'c' ), (b'a' , b'b' , b'c' )])
105105
106106
107107def test_list_object_tuple () -> None :
108108 _test_invariance (
109- read , write , b '<' , b 'h' , [(b 'c' , b 'c' ), b 'c' ], b'\2 \0 abcabc' ,
109+ read , write , '<' , 'h' , [('c' , 'c' ), 'c' ], b'\2 \0 abcabc' ,
110110 [(b'a' , b'b' ), b'c' , (b'a' , b'b' ), b'c' ])
0 commit comments