FIX test_video_scorer: use tmp_path for sample video so tests are xdist-safe#1795
Merged
Merged
Conversation
…st-safe The video_converter_sample_video fixture wrote its sample MP4 to a CWD-relative path. Under pytest-xdist's default --dist=load mode, the file's tests shard across workers that share the same CWD and race on a single test_video.mp4, producing flaky FileNotFoundError. CI uses --dist=loadfile (Makefile) which pins file-to-worker and masks the race, so this only bites devs running plain pytest -n auto locally. Switch the fixture to pytest's tmp_path. Same pattern already used by tests/unit/prompt_converter/test_add_image_video_converter.py.
Contributor
Author
|
Appreciate the feedback. Thank you ! |
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.
Fixes #1794.
The
video_converter_sample_videofixture intests/unit/score/test_video_scorer.pywrote its sample MP4 to a CWD-relative path ("test_video.mp4"). Underpytest-xdist -n auto(default--dist=load), the 17 tests in this file shard across workers that share the same CWD, racing on a single file and producing flakyFileNotFoundErrors.CI runs
pytest -n 4 --dist=loadfile(Makefile) which pins each file to one worker and masks the race, so this only bites devs running the xdist default locally.Fix
Inject
tmp_pathinto the fixture and place the sample video there. Per-test temp dirs are unique across workers, so the race vanishes. The same pattern is already used bytests/unit/prompt_converter/test_add_image_video_converter.py; this bringstest_video_scorer.pyin line.The explicit
os.path.exists/os.removeteardown is removed --tmp_pathcleans itself up.Verification