Skip to content

Commit

Permalink
Improve error message for detecting video backend (#1441)
Browse files Browse the repository at this point in the history
* Improve error message for detecting video backend

* Lint

* Add small test
  • Loading branch information
roomrys authored Aug 9, 2023
1 parent 1151a95 commit 2611e7d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sleap/io/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -1273,7 +1273,9 @@ def from_filename(cls, filename: str, *args, **kwargs) -> "Video":
elif filename.lower().endswith(SingleImageVideo.EXTS):
backend_class = SingleImageVideo
else:
raise ValueError("Could not detect backend for specified filename.")
raise ValueError(
f"Could not detect backend for specified filename: {filename}"
)

kwargs["filename"] = filename

Expand Down
3 changes: 3 additions & 0 deletions tests/io/test_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ def test_from_filename(hdf5_file_path, small_robot_mp4_path):
== SingleImageVideo
)

with pytest.raises(ValueError):
Video.from_filename("this_has_no_video_extension")


def test_backend_extra_kwargs(hdf5_file_path, small_robot_mp4_path):
Video.from_filename(hdf5_file_path, grayscale=True, another_kwarg=False)
Expand Down

0 comments on commit 2611e7d

Please sign in to comment.