Add test suite (75 tests) + fix platform-neutral install hints#1
Open
gatosa12 wants to merge 8 commits into
Open
Add test suite (75 tests) + fix platform-neutral install hints#1gatosa12 wants to merge 8 commits into
gatosa12 wants to merge 8 commits into
Conversation
Add tests for VTT parsing logic in transcribe.py
This file contains unit tests for the time parsing and FPS budget logic in scripts/frames.py. It includes tests for parse_time, format_time, _clamp_fps, auto_fps, and auto_fps_focus functions.
…for URL detection and file resolutionnctionality This file contains tests for the download module, including URL detection, local file resolution, and subtitle/video file picking logic. The tests cover various scenarios for each function, ensuring correct behavior.
Add .github/workflows/tests.yml: CI runs pytest on Python 3.10-3.12
…yt-dlp install hint (not just brew)essage Updated error message for missing yt-dlp installation to include installation instructions for both macOS and Linux/Windows.
…eg install hints (not just brew)ation instructions
gatosa12
commented
Apr 30, 2026
gatosa12
left a comment
Author
There was a problem hiding this comment.
Code Review
Great first test suite! Here's my full review:
✅ What's solid
tests/test_transcribe.py (22 tests)
- Good coverage of
parse_vttedge cases: HTML tag stripping, rolling/identical deduplication, comma decimal separators, and empty files. -
- The
_vtt()helper keeps fixtures concise.
- The
-
-
TestDedupeandTestFilterRangetest the pure functions cleanly in isolation.
-
-
-
-
TestFormatTranscriptroundtrip viaformat_time→parse_timeis a nice sanity check.
tests/test_frames.py(25 tests)
-
-
TestParseTimecovers all timestamp formats (MM:SS,HH:MM:SS, decimal variants) and passthrough of numeric types.-
TestAutoFpsFocus.test_denser_than_auto_fps_for_short_clipsis a good behavioral assertion (not just a value check).
-
-
fail-fast: falsein the CI matrix is the right call — you want to see all Python version failures at once.
tests/test_download.py(28 tests)
-
TestIsUrlcovers platform-specific paths (Windows backslash path, tilde, bare filename) — these are the cases most likely to regress.-
TestPickSubtitletests theenpreference logic and theen-US/en-GBvariant handling correctly.
scripts/download.py&scripts/frames.pybug fixes
- Platform-neutral install hints are correct and consistent across both files.
-
- The
auto_fps_focusdocstring fix (em-dash → hyphen) is a minor but appreciated cleanup.
- The
⚠️ Suggestions / things to watch
test_unknown_extension_warns_but_proceedsmay be fragile. The test asserts"warning" in captured.err.lower() or "xyz" in captured.err. Ifresolve_localdoesn't currently print to stderr for unknown extensions, this test will silently pass on theorbranch without actually validating the warning. Consider splitting into two separate assertions or usingpytest.warnsif a warning is raised.test_tilde_expansiondoesn't actually test tilde expansion. The comment says "Monkeypatch Path.expanduser to return tmp_path / 'video.mp4'" but the test just passes a real absolute path. It would be more valuable to callresolve_local("~/video.mp4")with a monkeypatchedexpanduser, or remove the test and rename it totest_absolute_path_works.TestAutoFps.test_30_second_boundaryuses a hard-coded expected max target of 30. If the fps budget algorithm changes, this test breaks without a clear explanation of why 30 is expected. Consider adding a brief comment explaining the intent (e.g., "30s clip should get at most 1 fps").- CI workflow only runs on
ubuntu-latest. The bug fixes are specifically about macOS/Windows install hints. It might be worth adding awindows-latestrunner row to actually exercise the Windows code path — even if just for the platform-neutral error message test. - No
conftest.pyor__init__.pyintests/. This is fine for now withpytest, but worth noting for future contributors. Aconftest.pycould house the_vtt()helper if more test files need it.
Summary
This is a clean, well-structured contribution. The tests are readable, isolated, and don't require any external binaries — exactly right for a CI-first setup. The bug fixes are correct. The suggestions above are minor; none are blockers. Ready to merge once CI passes.
Fix test failure: auto_fps_focus(3.0) was returning only 6 frames instead of the expected >=10. The _clamp_fps function was recalculating target after capping fps to MAX_FPS, which reduced the frame count. Now it preserves the originally intended target frame count while still capping the fps.
Fix indentation error from previous commit. Also fixes the frame calculation bug where auto_fps_focus(3.0) returned only 6 frames instead of >=10.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
This is the first test suite for the project, plus two bug fixes for Linux/Windows users.
New:
tests/— 75 unit tests (no external binaries required)tests/test_transcribe.pyparse_vtt,_dedupe,filter_range,format_transcripttests/test_frames.pyparse_time,format_time,_clamp_fps,auto_fps,auto_fps_focustests/test_download.pyis_url,resolve_local,_pick_subtitle,_pick_video,VIDEO_EXTSAll tests run with just
pip install pytest— no ffmpeg, yt-dlp, or API keys needed.New:
.github/workflows/tests.yml— CI workflowRuns the test suite on every push/PR against Python 3.10, 3.11, and 3.12.
Bug fixes: platform-neutral install hints
scripts/download.py— the error message whenyt-dlpisn't found previously saidbrew install yt-dlpon all platforms. Fixed to show the right command per OS.scripts/frames.py— same issue in two places forffmpeg/ffprobe. Fixed to show macOS / Linux / Windows install commands.How to run tests locally