4646
4747
4848def test_load_varint_too_long ():
49- with BytesIO (
50- b"\x80 \x80 \x80 \x80 \x80 \x80 \x80 \x80 \x80 \x80 \x01 "
51- ) as stream , pytest .raises (ValueError ):
49+ with (
50+ BytesIO (b"\x80 \x80 \x80 \x80 \x80 \x80 \x80 \x80 \x80 \x80 \x01 " ) as stream ,
51+ pytest .raises (ValueError ),
52+ ):
5253 betterproto .load_varint (stream )
5354
5455 with BytesIO (b"\x80 \x80 \x80 \x80 \x80 \x80 \x80 \x80 \x80 \x01 " ) as stream :
@@ -62,7 +63,7 @@ def test_load_varint_file():
6263 stream .read (2 ) # Skip until first multi-byte
6364 assert betterproto .load_varint (stream ) == (
6465 123456789 ,
65- b"\x95 \x9A \xEF \x3A " ,
66+ b"\x95 \x9a \xef \x3a " ,
6667 ) # Multi-byte varint
6768
6869
@@ -83,9 +84,10 @@ def test_dump_varint_file(tmp_path):
8384 betterproto .dump_varint (123456789 , stream ) # Multi-byte varint
8485
8586 # Check that file contents are as expected
86- with open (tmp_path / "dump_varint_file.out" , "rb" ) as test_stream , open (
87- streams_path / "message_dump_file_single.expected" , "rb"
88- ) as exp_stream :
87+ with (
88+ open (tmp_path / "dump_varint_file.out" , "rb" ) as test_stream ,
89+ open (streams_path / "message_dump_file_single.expected" , "rb" ) as exp_stream ,
90+ ):
8991 assert betterproto .load_varint (test_stream ) == betterproto .load_varint (
9092 exp_stream
9193 )
@@ -111,9 +113,10 @@ def test_message_dump_file_single(tmp_path):
111113 oneof_example .dump (stream )
112114
113115 # Check that the outputted file is exactly as expected
114- with open (tmp_path / "message_dump_file_single.out" , "rb" ) as test_stream , open (
115- streams_path / "message_dump_file_single.expected" , "rb"
116- ) as exp_stream :
116+ with (
117+ open (tmp_path / "message_dump_file_single.out" , "rb" ) as test_stream ,
118+ open (streams_path / "message_dump_file_single.expected" , "rb" ) as exp_stream ,
119+ ):
117120 assert test_stream .read () == exp_stream .read ()
118121
119122
@@ -125,9 +128,10 @@ def test_message_dump_file_multiple(tmp_path):
125128 nested_example .dump (stream )
126129
127130 # Check that all three Messages were outputted to the file correctly
128- with open (tmp_path / "message_dump_file_multiple.out" , "rb" ) as test_stream , open (
129- streams_path / "message_dump_file_multiple.expected" , "rb"
130- ) as exp_stream :
131+ with (
132+ open (tmp_path / "message_dump_file_multiple.out" , "rb" ) as test_stream ,
133+ open (streams_path / "message_dump_file_multiple.expected" , "rb" ) as exp_stream ,
134+ ):
131135 assert test_stream .read () == exp_stream .read ()
132136
133137
@@ -137,9 +141,10 @@ def test_message_dump_delimited(tmp_path):
137141 oneof_example .dump (stream , betterproto .SIZE_DELIMITED )
138142 nested_example .dump (stream , betterproto .SIZE_DELIMITED )
139143
140- with open (tmp_path / "message_dump_delimited.out" , "rb" ) as test_stream , open (
141- streams_path / "delimited_messages.in" , "rb"
142- ) as exp_stream :
144+ with (
145+ open (tmp_path / "message_dump_delimited.out" , "rb" ) as test_stream ,
146+ open (streams_path / "delimited_messages.in" , "rb" ) as exp_stream ,
147+ ):
143148 assert test_stream .read () == exp_stream .read ()
144149
145150
@@ -165,9 +170,10 @@ def test_message_load_file_multiple():
165170
166171
167172def test_message_load_too_small ():
168- with open (
169- streams_path / "message_dump_file_single.expected" , "rb"
170- ) as stream , pytest .raises (ValueError ):
173+ with (
174+ open (streams_path / "message_dump_file_single.expected" , "rb" ) as stream ,
175+ pytest .raises (ValueError ),
176+ ):
171177 oneof .Test ().load (stream , len_oneof - 1 )
172178
173179
@@ -180,9 +186,10 @@ def test_message_load_delimited():
180186
181187
182188def test_message_load_too_large ():
183- with open (
184- streams_path / "message_dump_file_single.expected" , "rb"
185- ) as stream , pytest .raises (ValueError ):
189+ with (
190+ open (streams_path / "message_dump_file_single.expected" , "rb" ) as stream ,
191+ pytest .raises (ValueError ),
192+ ):
186193 oneof .Test ().load (stream , len_oneof + 1 )
187194
188195
@@ -272,9 +279,10 @@ def test_dump_varint_negative(tmp_path):
272279 with pytest .raises (ValueError ):
273280 betterproto .dump_varint (beyond , stream )
274281
275- with open (streams_path / "dump_varint_negative.expected" , "rb" ) as exp_stream , open (
276- tmp_path / "dump_varint_negative.out" , "rb"
277- ) as test_stream :
282+ with (
283+ open (streams_path / "dump_varint_negative.expected" , "rb" ) as exp_stream ,
284+ open (tmp_path / "dump_varint_negative.out" , "rb" ) as test_stream ,
285+ ):
278286 assert test_stream .read () == exp_stream .read ()
279287
280288
@@ -286,9 +294,10 @@ def test_dump_varint_positive(tmp_path):
286294 betterproto .dump_varint (single_byte , stream )
287295 betterproto .dump_varint (multi_byte , stream )
288296
289- with open (tmp_path / "dump_varint_positive.out" , "rb" ) as test_stream , open (
290- streams_path / "dump_varint_positive.expected" , "rb"
291- ) as exp_stream :
297+ with (
298+ open (tmp_path / "dump_varint_positive.out" , "rb" ) as test_stream ,
299+ open (streams_path / "dump_varint_positive.expected" , "rb" ) as exp_stream ,
300+ ):
292301 assert test_stream .read () == exp_stream .read ()
293302
294303
@@ -338,7 +347,7 @@ def run_java_single_varint(value: int, tmp_path) -> int:
338347
339348def test_single_varint (compile_jar , tmp_path ):
340349 single_byte = (1 , b"\x01 " )
341- multi_byte = (123456789 , b"\x95 \x9A \xEF \x3A " )
350+ multi_byte = (123456789 , b"\x95 \x9a \xef \x3a " )
342351
343352 # Write a single-byte varint to a file and have Java read it back
344353 returned = run_java_single_varint (single_byte [0 ], tmp_path )
@@ -351,8 +360,8 @@ def test_single_varint(compile_jar, tmp_path):
351360
352361def test_multiple_varints (compile_jar , tmp_path ):
353362 single_byte = (1 , b"\x01 " )
354- multi_byte = (123456789 , b"\x95 \x9A \xEF \x3A " )
355- over32 = (3000000000 , b"\x80 \xBC \xC1 \x96 \x0B " )
363+ multi_byte = (123456789 , b"\x95 \x9a \xef \x3a " )
364+ over32 = (3000000000 , b"\x80 \xbc \xc1 \x96 \x0b " )
356365
357366 # Write two varints to the same file
358367 with open (tmp_path / "py_multiple_varints.out" , "wb" ) as stream :
0 commit comments