@@ -89,25 +89,25 @@ def test_repr(self, monkeypatch):
89
89
f = Frame (0 )
90
90
monkeypatch .setattr (Frame , "serialize_body" , lambda _ : b"body" )
91
91
assert repr (f ) == (
92
- "Frame(stream_id: 0; flags: None ): 626f6479"
92
+ "Frame(stream_id=0, flags=[] ): <hex: 626f6479> "
93
93
)
94
94
95
95
f .stream_id = 42
96
96
f .flags = ["END_STREAM" , "PADDED" ]
97
97
assert repr (f ) == (
98
- "Frame(stream_id: 42; flags: END_STREAM, PADDED): 626f6479"
98
+ "Frame(stream_id=42, flags=[' END_STREAM', ' PADDED'] ): <hex: 626f6479> "
99
99
)
100
100
101
101
monkeypatch .setattr (Frame , "serialize_body" , lambda _ : b"A" * 25 )
102
102
assert repr (f ) == (
103
- "Frame(stream_id: 42; flags: END_STREAM, PADDED): {}..." .format ("41" * 10 )
103
+ "Frame(stream_id=42, flags=[' END_STREAM', ' PADDED'] ): <hex: {}...> " .format ("41" * 10 )
104
104
)
105
105
106
106
def test_frame_explain (self , capsys ):
107
107
d = b'\x00 \x00 \x08 \x00 \x01 \x00 \x00 \x00 \x01 testdata'
108
108
Frame .explain (memoryview (d ))
109
109
captured = capsys .readouterr ()
110
- assert captured .out .strip () == "DataFrame(stream_id: 1; flags: END_STREAM): 7465737464617461"
110
+ assert captured .out .strip () == "DataFrame(stream_id=1, flags=[' END_STREAM'] ): <hex: 7465737464617461> "
111
111
112
112
def test_cannot_parse_invalid_frame_header (self ):
113
113
with pytest .raises (InvalidFrameError ):
@@ -122,7 +122,7 @@ class TestDataFrame:
122
122
123
123
def test_repr (self ):
124
124
f = DataFrame (1 , b"testdata" )
125
- assert repr (f ).endswith ("7465737464617461" )
125
+ assert repr (f ).endswith ("<hex: 7465737464617461> " )
126
126
127
127
def test_data_frame_has_correct_flags (self ):
128
128
f = DataFrame (1 )
@@ -251,11 +251,11 @@ class TestPriorityFrame:
251
251
252
252
def test_repr (self ):
253
253
f = PriorityFrame (1 )
254
- assert repr (f ).endswith ("exclusive: False, depends_on: 0, stream_weight: 0" )
254
+ assert repr (f ).endswith ("exclusive= False, depends_on= 0, stream_weight= 0" )
255
255
f .exclusive = True
256
256
f .depends_on = 0x04
257
257
f .stream_weight = 64
258
- assert repr (f ).endswith ("exclusive: True, depends_on: 4, stream_weight: 64" )
258
+ assert repr (f ).endswith ("exclusive= True, depends_on= 4, stream_weight= 64" )
259
259
260
260
def test_priority_frame_has_no_flags (self ):
261
261
f = PriorityFrame (1 )
@@ -306,9 +306,9 @@ def test_short_priority_frame_errors(self):
306
306
class TestRstStreamFrame :
307
307
def test_repr (self ):
308
308
f = RstStreamFrame (1 )
309
- assert repr (f ).endswith ("error_code: 0" )
309
+ assert repr (f ).endswith ("error_code= 0" )
310
310
f .error_code = 420
311
- assert repr (f ).endswith ("error_code: 420" )
311
+ assert repr (f ).endswith ("error_code= 420" )
312
312
313
313
def test_rst_stream_frame_has_no_flags (self ):
314
314
f = RstStreamFrame (1 )
@@ -366,9 +366,9 @@ class TestSettingsFrame:
366
366
367
367
def test_repr (self ):
368
368
f = SettingsFrame ()
369
- assert repr (f ).endswith ("settings: {}" )
369
+ assert repr (f ).endswith ("settings= {}" )
370
370
f .settings [SettingsFrame .MAX_FRAME_SIZE ] = 16384
371
- assert repr (f ).endswith ("settings: {5: 16384}" )
371
+ assert repr (f ).endswith ("settings= {5: 16384}" )
372
372
373
373
def test_settings_frame_has_only_one_flag (self ):
374
374
f = SettingsFrame ()
@@ -431,10 +431,10 @@ def test_short_settings_frame_errors(self):
431
431
class TestPushPromiseFrame :
432
432
def test_repr (self ):
433
433
f = PushPromiseFrame (1 )
434
- assert repr (f ).endswith ("promised_stream_id: 0, data: None" )
434
+ assert repr (f ).endswith ("promised_stream_id= 0, data= None" )
435
435
f .promised_stream_id = 4
436
436
f .data = b"testdata"
437
- assert repr (f ).endswith ("promised_stream_id: 4, data: 7465737464617461" )
437
+ assert repr (f ).endswith ("promised_stream_id= 4, data=<hex: 7465737464617461> " )
438
438
439
439
def test_push_promise_frame_flags (self ):
440
440
f = PushPromiseFrame (1 )
@@ -523,9 +523,9 @@ def test_short_push_promise_errors(self):
523
523
class TestPingFrame :
524
524
def test_repr (self ):
525
525
f = PingFrame ()
526
- assert repr (f ).endswith ("opaque_data: b''" )
526
+ assert repr (f ).endswith ("opaque_data= b''" )
527
527
f .opaque_data = b'hello'
528
- assert repr (f ).endswith ("opaque_data: b'hello'" )
528
+ assert repr (f ).endswith ("opaque_data= b'hello'" )
529
529
530
530
def test_ping_frame_has_only_one_flag (self ):
531
531
f = PingFrame ()
@@ -581,11 +581,11 @@ def test_ping_frame_has_no_less_than_body_length_8(self):
581
581
class TestGoAwayFrame :
582
582
def test_repr (self ):
583
583
f = GoAwayFrame ()
584
- assert repr (f ).endswith ("last_stream_id: 0, error_code: 0, additional_data: b''" )
584
+ assert repr (f ).endswith ("last_stream_id= 0, error_code= 0, additional_data= b''" )
585
585
f .last_stream_id = 64
586
586
f .error_code = 32
587
587
f .additional_data = b'hello'
588
- assert repr (f ).endswith ("last_stream_id: 64, error_code: 32, additional_data: b'hello'" )
588
+ assert repr (f ).endswith ("last_stream_id= 64, error_code= 32, additional_data= b'hello'" )
589
589
590
590
def test_go_away_has_no_flags (self ):
591
591
f = GoAwayFrame ()
@@ -652,10 +652,10 @@ def test_short_goaway_frame_errors(self):
652
652
class TestWindowUpdateFrame :
653
653
def test_repr (self ):
654
654
f = WindowUpdateFrame (0 )
655
- assert repr (f ).endswith ("window_increment: 0" )
655
+ assert repr (f ).endswith ("window_increment= 0" )
656
656
f .stream_id = 1
657
657
f .window_increment = 512
658
- assert repr (f ).endswith ("window_increment: 512" )
658
+ assert repr (f ).endswith ("window_increment= 512" )
659
659
660
660
def test_window_update_has_no_flags (self ):
661
661
f = WindowUpdateFrame (0 )
@@ -699,12 +699,12 @@ def test_short_windowupdate_frame_errors(self):
699
699
class TestHeadersFrame :
700
700
def test_repr (self ):
701
701
f = HeadersFrame (1 )
702
- assert repr (f ).endswith ("exclusive: False, depends_on: 0, stream_weight: 0, data: None" )
702
+ assert repr (f ).endswith ("exclusive= False, depends_on= 0, stream_weight= 0, data= None" )
703
703
f .data = b'hello'
704
704
f .exclusive = True
705
705
f .depends_on = 42
706
706
f .stream_weight = 64
707
- assert repr (f ).endswith ("exclusive: True, depends_on: 42, stream_weight: 64, data: 68656c6c6f" )
707
+ assert repr (f ).endswith ("exclusive= True, depends_on= 42, stream_weight= 64, data=<hex: 68656c6c6f> " )
708
708
709
709
def test_headers_frame_flags (self ):
710
710
f = HeadersFrame (1 )
@@ -790,9 +790,9 @@ def test_headers_frame_with_no_length_parses(self):
790
790
class TestContinuationFrame :
791
791
def test_repr (self ):
792
792
f = ContinuationFrame (1 )
793
- assert repr (f ).endswith ("data: None" )
793
+ assert repr (f ).endswith ("data= None" )
794
794
f .data = b'hello'
795
- assert repr (f ).endswith ("data: 68656c6c6f" )
795
+ assert repr (f ).endswith ("data=<hex: 68656c6c6f> " )
796
796
797
797
def test_continuation_frame_flags (self ):
798
798
f = ContinuationFrame (1 )
@@ -852,11 +852,11 @@ class TestAltSvcFrame:
852
852
853
853
def test_repr (self ):
854
854
f = AltSvcFrame (0 )
855
- assert repr (f ).endswith ("origin: b'', field: b''" )
855
+ assert repr (f ).endswith ("origin= b'', field= b''" )
856
856
f .field = b'h2="alt.example.com:8000", h2=":443"'
857
- assert repr (f ).endswith ("origin: b'', field: b'h2=\" alt.example.com:8000\" , h2=\" :443\" '" )
857
+ assert repr (f ).endswith ("origin= b'', field= b'h2=\" alt.example.com:8000\" , h2=\" :443\" '" )
858
858
f .origin = b'example.com'
859
- assert repr (f ).endswith ("origin: b'example.com', field: b'h2=\" alt.example.com:8000\" , h2=\" :443\" '" )
859
+ assert repr (f ).endswith ("origin= b'example.com', field= b'h2=\" alt.example.com:8000\" , h2=\" :443\" '" )
860
860
861
861
def test_altsvc_frame_flags (self ):
862
862
f = AltSvcFrame (0 )
@@ -927,4 +927,4 @@ def test_altsvc_with_unicode_field_fails(self):
927
927
class TestExtensionFrame :
928
928
def test_repr (self ):
929
929
f = ExtensionFrame (0xFF , 1 , 42 , b'hello' )
930
- assert repr (f ).endswith ("type: 255, flag_byte: 42, body: 68656c6c6f" )
930
+ assert repr (f ).endswith ("type= 255, flag_byte= 42, body=<hex: 68656c6c6f> " )
0 commit comments