Skip to content

Commit 3204722

Browse files
committed
Add tests for out of range negative index
1 parent 1b75a95 commit 3204722

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

test/test_decoders.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,9 @@ def test_get_frame_at_tuple_unpacking(self, device):
487487
def test_get_frame_at_fails(self, device, seek_mode):
488488
decoder = VideoDecoder(NASA_VIDEO.path, device=device, seek_mode=seek_mode)
489489

490+
with pytest.raises(IndexError, match="out of bounds"):
491+
frame = decoder.get_frame_at(-10000) # noqa
492+
490493
with pytest.raises(IndexError, match="out of bounds"):
491494
frame = decoder.get_frame_at(10000) # noqa
492495

@@ -546,6 +549,12 @@ def test_get_frames_at(self, device, seek_mode):
546549
def test_get_frames_at_fails(self, device, seek_mode):
547550
decoder = VideoDecoder(NASA_VIDEO.path, device=device, seek_mode=seek_mode)
548551

552+
expected_converted_index = -10000 + len(decoder)
553+
with pytest.raises(
554+
RuntimeError, match=f"Invalid frame index={expected_converted_index}"
555+
):
556+
decoder.get_frames_at([-10000])
557+
549558
with pytest.raises(RuntimeError, match="Invalid frame index=390"):
550559
decoder.get_frames_at([390])
551560

0 commit comments

Comments
 (0)