4646
4747
4848def test_load_varint_too_long ():
49- with (
50- BytesIO (b"\x80 \x80 \x80 \x80 \x80 \x80 \x80 \x80 \x80 \x80 \x01 " ) as stream ,
51- pytest .raises (ValueError ),
52- ):
49+ with BytesIO (
50+ b"\x80 \x80 \x80 \x80 \x80 \x80 \x80 \x80 \x80 \x80 \x01 "
51+ ) as stream , pytest .raises (ValueError ):
5352 betterproto .load_varint (stream )
5453
5554 with BytesIO (b"\x80 \x80 \x80 \x80 \x80 \x80 \x80 \x80 \x80 \x01 " ) as stream :
@@ -84,10 +83,9 @@ def test_dump_varint_file(tmp_path):
8483 betterproto .dump_varint (123456789 , stream ) # Multi-byte varint
8584
8685 # Check that file contents are as expected
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- ):
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 :
9189 assert betterproto .load_varint (test_stream ) == betterproto .load_varint (
9290 exp_stream
9391 )
@@ -113,10 +111,9 @@ def test_message_dump_file_single(tmp_path):
113111 oneof_example .dump (stream )
114112
115113 # Check that the outputted file is exactly as expected
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- ):
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 :
120117 assert test_stream .read () == exp_stream .read ()
121118
122119
@@ -128,10 +125,9 @@ def test_message_dump_file_multiple(tmp_path):
128125 nested_example .dump (stream )
129126
130127 # Check that all three Messages were outputted to the file correctly
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- ):
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 :
135131 assert test_stream .read () == exp_stream .read ()
136132
137133
@@ -141,10 +137,9 @@ def test_message_dump_delimited(tmp_path):
141137 oneof_example .dump (stream , betterproto .SIZE_DELIMITED )
142138 nested_example .dump (stream , betterproto .SIZE_DELIMITED )
143139
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- ):
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 :
148143 assert test_stream .read () == exp_stream .read ()
149144
150145
@@ -170,10 +165,9 @@ def test_message_load_file_multiple():
170165
171166
172167def test_message_load_too_small ():
173- with (
174- open (streams_path / "message_dump_file_single.expected" , "rb" ) as stream ,
175- pytest .raises (ValueError ),
176- ):
168+ with open (
169+ streams_path / "message_dump_file_single.expected" , "rb"
170+ ) as stream , pytest .raises (ValueError ):
177171 oneof .Test ().load (stream , len_oneof - 1 )
178172
179173
@@ -186,10 +180,9 @@ def test_message_load_delimited():
186180
187181
188182def test_message_load_too_large ():
189- with (
190- open (streams_path / "message_dump_file_single.expected" , "rb" ) as stream ,
191- pytest .raises (ValueError ),
192- ):
183+ with open (
184+ streams_path / "message_dump_file_single.expected" , "rb"
185+ ) as stream , pytest .raises (ValueError ):
193186 oneof .Test ().load (stream , len_oneof + 1 )
194187
195188
@@ -279,10 +272,9 @@ def test_dump_varint_negative(tmp_path):
279272 with pytest .raises (ValueError ):
280273 betterproto .dump_varint (beyond , stream )
281274
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- ):
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 :
286278 assert test_stream .read () == exp_stream .read ()
287279
288280
@@ -294,10 +286,9 @@ def test_dump_varint_positive(tmp_path):
294286 betterproto .dump_varint (single_byte , stream )
295287 betterproto .dump_varint (multi_byte , stream )
296288
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- ):
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 :
301292 assert test_stream .read () == exp_stream .read ()
302293
303294
0 commit comments