FIX: use tmp_path for hardcoded test files to fix xdist races#1797
Merged
romanlutz merged 1 commit intoMay 26, 2026
Merged
Conversation
Three tests wrote to CWD-relative hardcoded paths (`test.png`, `sample_file.png`) and cleaned them up manually. Under `pytest -n auto` (default `--dist=load`) workers share CWD and race on these names. Worse, two of the files used the same `test.png` so they raced across files even under CI's `--dist=loadfile`. Inject `tmp_path` into each test and write under it. The per-test temp dir is unique per worker, removing the race, and pytest cleans it up automatically so manual `os.remove` calls go away. Same pattern as microsoft#1795 (test_video_scorer.py). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
behnam-o
approved these changes
May 26, 2026
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 the same xdist race as #1795, in three more places.
Three unit tests write to CWD-relative hardcoded paths (
test.png,sample_file.png) and clean them up manually:tests/unit/prompt_converter/test_add_text_image_converter.pytests/unit/models/test_seed.pytests/unit/prompt_converter/test_qr_code_converter.pyUnder
pytest -n auto(default--dist=load) workers share CWD and race on these names. Worse, the first two use the same filenametest.png, so they race across files even under CI's--dist=loadfile.Fix
Inject
tmp_pathinto each test and write under it. Per-test temp dirs are unique per worker; pytest cleans them up, so manualos.removecalls go away too. Same surgical pattern as #1795.Verification
pytest <files>sequentially: 124 passed in ~25spytest <files> -n autox5 runs: 124 passed every runNotes
Investigation and patch were drafted with Copilot CLI assistance during review of #1795; I verified the bug pattern and validated the fix.