Conversation
Add conftest.py that ensures tests/ is on sys.path so test modules in subdirectories can import from common. Add __init__.py files to all tool-specific test subdirectories.
Relocate all merge-related test files under tests/merge/: - test_merge_subtitles.py → merge/test_subtitles.py - test_merge_language_detection.py → merge/test_language_detection.py - test_merge_errors_reaction.py → merge/test_errors_reaction.py - test_merge_subtitles_conversion.py → merge/test_subtitles_conversion.py - test_mkvmerge_subtitle_formats.py → merge/test_mkvmerge_subtitle_formats.py
Relocate tool-specific test files: - test_concatenate.py → concatenate/test_concatenate.py - test_language_fixer.py → language_fixer/test_language_fixer.py - test_subtitles_fixer.py → subtitles_fixer/test_subtitles_fixer.py - test_transcoder.py → transcode/test_transcoder.py - test_utilities_scenes.py → utilities/test_scenes.py
Relocate utility test files: - test_utils.py → utils/test_video_utils.py - test_requirements_utils.py → utils/test_requirements_utils.py
Break the monolithic 3337-line test_melt.py into 7 focused files under tests/melt/: - helpers.py: shared MeltTestBase class, setUp fixtures, and module-level utilities (normalize, all_key_orders, etc.) - test_integration.py: MeltIntegrationTest — basic duplicate detection, dry-run, inputs, length mismatch, multi-input, stream ordering, subtitles, attachments (16 tests) - test_streams_picker.py: StreamsPickerTest — audio/video preference, force-all-streams, argument parsing (14 tests) - test_pair_matcher_integration.py: PairMatcherIntegrationTest — real video pair matching, edge cases, coverage summary (15 tests) - test_audio_alignment.py: AudioAlignmentTest — beep-based audio timing verification after melt (1 test) - test_performer_unit.py: MeltPerformerUnitTest — audio patching, stream sorting, FLAC concat, mkvmerge args, sync offset (41 tests) - test_pair_matcher_unit.py: PairMatcherUnitTest — extrapolation, edge snapping, constant-offset detection, boundary search (25 tests) All 111 melt tests pass.
The test_force_all_streams_parser_requires_preceding_input test correctly asserted SystemExit, but argparse.error() prints usage and error message to stderr before raising. Redirect stderr with contextlib.redirect_stderr to keep test output clean.
Relocate audio/, images/, videos/ (submodules), subtitles/ and subtitles_txt/ into tests/media/ to clearly separate test fixture data from test code. Replace hardcoded current_path/videos/ paths in test_subtitles_fixer with get_video() helper. Add media_path variable in common.py and update all fixture accessor functions to use it.
This reverts commit 105841d.
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Reorganizes the test suite by splitting the previously monolithic melt test module into a structured tests/melt/ package, and updates test media path handling to align with the new tests/media/ submodule layout.
Changes:
- Split
tests/test_melt.pyinto multiple focused test modules undertests/melt/with shared utilities intests/melt/helpers.py. - Migrate test media references to
tests/media/*(via.gitmodules+tests/common.py) and update subtitles fixer tests to useget_video(). - Add
tests/conftest.pyto makefrom common import ...work from subdirectories and hardenrun_twotone()against mutable default args.
Reviewed changes
Copilot reviewed 19 out of 48 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/utils/init.py | Adds package marker for tests/utils (currently includes whitespace-only content). |
| tests/utilities/init.py | Adds package marker for tests/utilities (currently includes whitespace-only content). |
| tests/transcode/init.py | Adds package marker for tests/transcode (currently includes whitespace-only content). |
| tests/test_subtitles_fixer.py | Switches video fixture path usage from current_path to get_video(). |
| tests/test_melt.py | Removes the large combined melt test module in favor of per-area modules. |
| tests/subtitles_fixer/init.py | Adds package marker for tests/subtitles_fixer (currently includes whitespace-only content). |
| tests/merge/init.py | Adds package marker for tests/merge (currently includes whitespace-only content). |
| tests/melt/test_streams_picker.py | New streams-picker focused tests + shared helper imports. |
| tests/melt/test_performer_unit.py | New MeltPerformer unit tests module extracted from prior suite. |
| tests/melt/test_pair_matcher_unit.py | New PairMatcher unit tests module extracted from prior suite. |
| tests/melt/test_pair_matcher_integration.py | New PairMatcher integration tests module extracted from prior suite. |
| tests/melt/test_integration.py | New melt end-to-end integration tests module extracted from prior suite. |
| tests/melt/test_audio_alignment.py | New audio-alignment integration test module extracted from prior suite. |
| tests/melt/helpers.py | Shared helper functions + MeltTestBase fixture generation extracted from prior suite. |
| tests/melt/init.py | Adds package marker for tests/melt (currently includes whitespace-only content). |
| tests/language_fixer/init.py | Adds package marker for tests/language_fixer (currently includes whitespace-only content). |
| tests/conftest.py | Adds tests/ to sys.path to support from common import ... across subpackages. |
| tests/concatenate/init.py | Adds package marker for tests/concatenate (currently includes whitespace-only content). |
| tests/common.py | Introduces media_path and updates media/subtitle/audio/image path helpers accordingly; fixes run_twotone() defaults. |
| .gitmodules | Moves media submodules to tests/media/{videos,audio,images}. |
Comments suppressed due to low confidence (2)
tests/melt/test_streams_picker.py:1
TwoToneTestCaseis imported but not referenced anywhere in this file. Please remove the unused import to avoid lint/test hygiene failures (e.g., flake8/ruff F401).
tests/melt/test_streams_picker.py:1MeltTestBase.setUp()generates/caches large video fixtures and edge-case files;StreamsPickerTestappears to only exercise pure selection logic and metadata parsing. Inheriting fromMeltTestBasemakes these unit tests pay an unnecessary setup cost (and can be very slow in CI without a persistent cache). Consider inheriting fromTwoToneTestCase(or introducing a lightweight base) for this file, reservingMeltTestBasefor integration tests that actually needsample_video_file/edge_fixtures.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| # Ensure tests/ is on sys.path so that test modules in subdirectories | ||
| # can use ``from common import ...`` the same way top-level tests do. | ||
| sys.path.insert(0, os.path.dirname(__file__)) |
There was a problem hiding this comment.
Unconditionally inserting tests/ at the front of sys.path can shadow similarly named top-level modules (e.g., common, melt, etc.) and can also lead to duplicate entries if imported multiple times. A safer pattern is to (1) only insert if not already present and/or (2) prefer package-relative imports inside tests/ (e.g., from .helpers import ...) to avoid global import side-effects.
| sys.path.insert(0, os.path.dirname(__file__)) | |
| tests_dir = os.path.dirname(__file__) | |
| if tests_dir not in sys.path: | |
| sys.path.insert(0, tests_dir) |
| for media in ["subtitles", "subtitles_txt", "videos"]: | ||
| for root, _, files in os.walk(os.path.join(current_path, media)): | ||
| for root, _, files in os.walk(os.path.join(media_path, media)): |
There was a problem hiding this comment.
add_test_media() now searches for subtitles and subtitles_txt under media_path (i.e., tests/media/...). In this PR, .gitmodules only moves videos, audio, and images into tests/media/, so unless subtitle fixtures were also moved to tests/media/subtitles*, this change will break test fixture discovery for subtitles. If subtitles are not under tests/media/, consider keeping subtitles/subtitles_txt rooted at current_path while only using media_path for submodule-backed assets.
| #unify fps and add audio path | ||
| output_dir = os.path.join(self.wd.path, "gen_sample") | ||
|
|
||
| with ScopedDirectory(output_dir) as sd: |
There was a problem hiding this comment.
The context manager variable sd is never used. If this repository enforces unused-variable checks, this can fail linting (e.g., ruff/flake8 F841). If you don't need the bound value, use with ScopedDirectory(output_dir):.
| with ScopedDirectory(output_dir) as sd: | |
| with ScopedDirectory(output_dir): |
| @@ -0,0 +1 @@ | |||
|
|
|||
There was a problem hiding this comment.
These newly added __init__.py files appear to contain whitespace-only content (a single blank line). If lint rules like W293 blank line contains whitespace are enabled, this can fail. Prefer truly empty __init__.py files (0 bytes) or at least ensure the line has no trailing spaces. This applies to the other newly added tests/**/__init__.py files showing the same pattern.
No description provided.