Skip to content

Commit a9d2a93

Browse files
committed
add test case to catch generic avcodec_open2 failed
1 parent 2a49a3d commit a9d2a93

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

test/test_encoders.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ def test_bad_input_parameterized(self, tmp_path, method):
610610
)
611611
getattr(encoder, method)(**valid_params)
612612

613-
def test_bad_input(self, tmp_path):
613+
def test_bad_input(self):
614614
encoder = VideoEncoder(
615615
frames=torch.zeros((5, 3, 64, 64), dtype=torch.uint8),
616616
frame_rate=30,
@@ -634,6 +634,12 @@ def test_bad_input(self, tmp_path):
634634
):
635635
encoder.to_tensor(format="bad_format")
636636

637+
with pytest.raises(
638+
RuntimeError,
639+
match=r"avcodec_open2 failed: Invalid argument",
640+
):
641+
encoder.to_tensor(format="mp4", preset="fake_preset")
642+
637643
@pytest.mark.parametrize("method", ("to_file", "to_tensor", "to_file_like"))
638644
def test_pixel_format_errors(self, method, tmp_path):
639645
frames = torch.zeros((5, 3, 64, 64), dtype=torch.uint8)

0 commit comments

Comments
 (0)