99import pytest
1010
1111# local
12- from telnetlib3 .telopt import (
13- DO ,
14- SB ,
15- SE ,
16- IAC ,
17- DONT ,
18- WILL ,
19- WONT ,
20- MCCP2_COMPRESS ,
21- MCCP3_COMPRESS ,
22- )
12+ from telnetlib3 .telopt import DO , SB , SE , IAC , DONT , WILL , WONT , MCCP2_COMPRESS , MCCP3_COMPRESS
2313from telnetlib3 .stream_writer import TelnetWriter
2414from telnetlib3 .tests .accessories import MockProtocol , MockTransport
2515
@@ -184,9 +174,7 @@ def test_mid_chunk_split(self):
184174 compressed += compressor .flush (zlib .Z_SYNC_FLUSH )
185175
186176 chunk = IAC + SB + MCCP2_COMPRESS + IAC + SE + compressed
187- cmd_received = _process_data_chunk (
188- chunk , w , reader , None , lambda * a : None
189- )
177+ cmd_received = _process_data_chunk (chunk , w , reader , None , lambda * a : None )
190178 assert cmd_received is True
191179 assert w .mccp2_active is True
192180 assert w ._compressed_remainder == compressed
@@ -200,9 +188,7 @@ def test_no_remainder_without_mccp2(self):
200188 w , _t , _p = new_writer (server = False , client = True , reader = reader )
201189
202190 chunk = b"plain text data"
203- cmd_received = _process_data_chunk (
204- chunk , w , reader , None , lambda * a : None
205- )
191+ cmd_received = _process_data_chunk (chunk , w , reader , None , lambda * a : None )
206192 assert cmd_received is False
207193 assert w ._compressed_remainder is None
208194
@@ -249,11 +235,7 @@ def test_initial_attributes(self):
249235 assert w .mccp2_active is False
250236 assert w .mccp3_active is False
251237
252- @pytest .mark .parametrize (
253- "opt" ,
254- [MCCP2_COMPRESS , MCCP3_COMPRESS ],
255- ids = ["MCCP2" , "MCCP3" ],
256- )
238+ @pytest .mark .parametrize ("opt" , [MCCP2_COMPRESS , MCCP3_COMPRESS ], ids = ["MCCP2" , "MCCP3" ])
257239 def test_empty_sb_allowed (self , opt ):
258240 w , _t , _p = new_writer (server = False , client = True )
259241 w .pending_option [SB + opt ] = True
@@ -275,7 +257,10 @@ def _make_compressed(plaintext: bytes, finish: bool = False) -> bytes:
275257_BOUNDARY_SB = IAC + SB + MCCP2_COMPRESS + IAC + SE
276258_BOUNDARY_FULL = _BOUNDARY_SB + _BOUNDARY_COMPRESSED
277259_BOUNDARY_SPLITS = [
278- 1 , 2 , 3 , 4 ,
260+ 1 ,
261+ 2 ,
262+ 3 ,
263+ 4 ,
279264 len (_BOUNDARY_SB ) - 1 ,
280265 len (_BOUNDARY_SB ),
281266 len (_BOUNDARY_SB ) + 1 ,
@@ -317,11 +302,7 @@ async def test_two_chunk_delivery(self, split_at):
317302 joined = b"" .join (received )
318303 assert joined == _BOUNDARY_PLAINTEXT
319304
320- @pytest .mark .parametrize (
321- "n_chunks" ,
322- [3 , 5 , 10 ],
323- ids = ["3_chunks" , "5_chunks" , "10_chunks" ],
324- )
305+ @pytest .mark .parametrize ("n_chunks" , [3 , 5 , 10 ], ids = ["3_chunks" , "5_chunks" , "10_chunks" ])
325306 async def test_multi_chunk_delivery (self , n_chunks ):
326307 """Compressed data delivered in many small chunks."""
327308 client , received = _make_client_with_capture ()
@@ -347,9 +328,7 @@ async def test_z_finish_with_trailing_plaintext(self):
347328 assert joined == plaintext + trailing
348329
349330 @pytest .mark .parametrize (
350- "split_at" ,
351- [1 , 4 , 8 , 16 ],
352- ids = ["byte_1" , "byte_4" , "byte_8" , "byte_16" ],
331+ "split_at" , [1 , 4 , 8 , 16 ], ids = ["byte_1" , "byte_4" , "byte_8" , "byte_16" ]
353332 )
354333 async def test_compressed_only_boundary (self , split_at ):
355334 """Split within compressed data only (SB already processed)."""
0 commit comments