Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fca354a

Browse files
Kriechipgjones
authored andcommitted
tests: assert the correct expected exception type
1 parent 1973f07 commit fca354a

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

test/test_frames.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def test_data_frame_without_padding_calculates_flow_control_len(self):
179179
assert f.flow_controlled_length == 8
180180

181181
def test_data_frame_comes_on_a_stream(self):
182-
with pytest.raises(ValueError):
182+
with pytest.raises(InvalidFrameError):
183183
DataFrame(0)
184184

185185
def test_long_data_frame(self):
@@ -263,13 +263,13 @@ def test_priority_frame_with_all_data_parses_properly(self):
263263
assert f.body_len == 5
264264

265265
def test_priority_frame_invalid(self):
266-
with pytest.raises(ValueError):
266+
with pytest.raises(InvalidFrameError):
267267
decode_frame(
268268
b'\x00\x00\x06\x02\x00\x00\x00\x00\x01\x80\x00\x00\x04\x40\xFF'
269269
)
270270

271271
def test_priority_frame_comes_on_a_stream(self):
272-
with pytest.raises(ValueError):
272+
with pytest.raises(InvalidFrameError):
273273
PriorityFrame(0)
274274

275275
def test_short_priority_frame_errors(self):
@@ -301,12 +301,12 @@ def test_rst_stream_frame_parses_properly(self):
301301
assert f.body_len == 4
302302

303303
def test_rst_stream_frame_comes_on_a_stream(self):
304-
with pytest.raises(ValueError):
304+
with pytest.raises(InvalidFrameError):
305305
RstStreamFrame(0)
306306

307307
def test_rst_stream_frame_must_have_body_length_four(self):
308308
f = RstStreamFrame(1)
309-
with pytest.raises(ValueError):
309+
with pytest.raises(InvalidFrameError):
310310
f.parse_body(b'\x01')
311311

312312

@@ -358,10 +358,10 @@ def test_settings_frame_with_ack(self):
358358
assert 'ACK' in f.flags
359359

360360
def test_settings_frame_ack_and_settings(self):
361-
with pytest.raises(ValueError):
361+
with pytest.raises(InvalidFrameError):
362362
SettingsFrame(settings=self.settings, flags=('ACK',))
363363

364-
with pytest.raises(ValueError):
364+
with pytest.raises(InvalidFrameError):
365365
decode_frame(self.serialized)
366366

367367
def test_settings_frame_parses_properly(self):
@@ -376,13 +376,13 @@ def test_settings_frame_parses_properly(self):
376376
assert f.body_len == 42
377377

378378
def test_settings_frame_invalid_body_length(self):
379-
with pytest.raises(ValueError):
379+
with pytest.raises(InvalidFrameError):
380380
decode_frame(
381381
b'\x00\x00\x2A\x04\x00\x00\x00\x00\x00\xFF\xFF\xFF\xFF'
382382
)
383383

384384
def test_settings_frames_never_have_streams(self):
385-
with pytest.raises(ValueError):
385+
with pytest.raises(InvalidFrameError):
386386
SettingsFrame(stream_id=1)
387387

388388
def test_short_settings_frame_errors(self):
@@ -497,7 +497,7 @@ def test_no_more_than_8_octets(self):
497497
f = PingFrame()
498498
f.opaque_data = b'\x01\x02\x03\x04\x05\x06\x07\x08\x09'
499499

500-
with pytest.raises(ValueError):
500+
with pytest.raises(InvalidFrameError):
501501
f.serialize()
502502

503503
def test_ping_frame_parses_properly(self):
@@ -513,17 +513,17 @@ def test_ping_frame_parses_properly(self):
513513
assert f.body_len == 8
514514

515515
def test_ping_frame_never_has_a_stream(self):
516-
with pytest.raises(ValueError):
516+
with pytest.raises(InvalidFrameError):
517517
PingFrame(stream_id=1)
518518

519519
def test_ping_frame_has_no_more_than_body_length_8(self):
520520
f = PingFrame()
521-
with pytest.raises(ValueError):
521+
with pytest.raises(InvalidFrameError):
522522
f.parse_body(b'\x01\x02\x03\x04\x05\x06\x07\x08\x09')
523523

524524
def test_ping_frame_has_no_less_than_body_length_8(self):
525525
f = PingFrame()
526-
with pytest.raises(ValueError):
526+
with pytest.raises(InvalidFrameError):
527527
f.parse_body(b'\x01\x02\x03\x04\x05\x06\x07')
528528

529529

@@ -577,7 +577,7 @@ def test_goaway_frame_parses_properly(self):
577577
assert f.body_len == 8
578578

579579
def test_goaway_frame_never_has_a_stream(self):
580-
with pytest.raises(ValueError):
580+
with pytest.raises(InvalidFrameError):
581581
GoAwayFrame(stream_id=1)
582582

583583
def test_short_goaway_frame_errors(self):
@@ -829,14 +829,14 @@ def test_short_altsvc_frame_errors(self):
829829
decode_frame(self.payload_with_origin[:10])
830830

831831
def test_altsvc_with_unicode_origin_fails(self):
832-
with pytest.raises(ValueError):
832+
with pytest.raises(InvalidFrameError):
833833
AltSvcFrame(
834834
stream_id=0, origin=u'hello', field=b'h2=":8000"; ma=60'
835835

836836
)
837837

838838
def test_altsvc_with_unicode_field_fails(self):
839-
with pytest.raises(ValueError):
839+
with pytest.raises(InvalidFrameError):
840840
AltSvcFrame(
841841
stream_id=0, origin=b'hello', field=u'h2=":8000"; ma=60'
842842
)

0 commit comments

Comments
 (0)