tests/test_generate_images.py::test_generate_og_images collides with itself under concurrent pytest runs (fixed-name temp dir under the real repo root, not inside pytest's tmp_path)
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 75/100
Direzione di ricerca
Il problema si trova in tests/test_generate_images.py nella funzione test_generate_og_images. Osserva come test_root viene costruito utilizzando script.ROOT e tmp_path.name. La correzione consiste nell'usare l'unico tmp_path fornito da pytest. Leggi il test per comprendere il monkeypatching delle directory di output. Esegui il test localmente e riproduci il problema di concorrenza per verificare la correzione. Assicurati che il test passi e che non rimangano directory residue dopo la pulizia.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Where: tests/test_generate_images.py, test_generate_og_images - specifically test_root = script.ROOT / f".tmp-test-{tmp_path.name}" followed by test_root.mkdir().
The gap: The test builds its scratch directory as script.ROOT / f".tmp-test-{tmp_path.name}" - i.e. under the real repository root (script.ROOT, a fixed path shared by every process), using only tmp_path.name (e.g. "test_generate_og_images0", which is deterministic per pytest session/worker, not globally unique) rather than the full, process-unique tmp_path. Two concurrent pytest invocations therefore compute the identical test_root path and race on mkdir().
Repro (single run passes cleanly):
$ python3 -m pytest tests/test_generate_images.py::test_generate_og_images -q
1 passed in 5.92s
Repro (two concurrent runs collide):
$ (python3 -m pytest tests/test_generate_images.py::test_generate_og_images -q > /tmp/run1.log 2>&1 &)
$ (python3 -m pytest tests/test_generate_images.py::test_generate_og_images -q > /tmp/run2.log 2>&1 &)
$ sleep 8; cat /tmp/run2.log
FAILED tests/test_generate_images.py::test_generate_og_images - FileExistsError: [Errno 17] File exists: '/Users/.../Fair-Code/.tmp-test-test_generate_og_images0'
The failing process hits FileExistsError on the mkdir() call itself, which sits before the try/finally cleanup block, so its own shutil.rmtree cleanup never even applies to it - the surviving directory is only ever cleaned up by whichever process created it, making the outcome timing-dependent. Confirmed no stray directory or git changes were left behind after a normal run (git status --short clean), but a differently-timed collision could leave one.
Fix direction: Use tmp_path itself (already unique per test invocation) or tmp_path_factory's base temp dir instead of constructing a new path under script.ROOT; if the script under test requires monkeypatching absolute output directories anyway (which this test already does), there's no need for test_root to live under the repo root at all.
- Lingua principale
- HTML
- Stelle
- 47
- Fork
- 45
- Merge medio
- 1h 53m
- PR unite (30g)
- 97
Preparare l'ambiente
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di yakew7/Fair-Code
-
bug documentation
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 95/100
I maintainer di solito rispondono entro 1 giorno
-
documentation good first issue
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 95/100
I maintainer di solito rispondono entro 1 giorno
-
documentation good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 92/100
yakew7/Fair-Code#731 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
enhancement help wanted
Difficoltà 4/5 3-5 giorni Idoneità per principianti 58/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di yakew7/Fair-Code
Issue simili
-
documentation easy good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
lacs-project/sysknife#518 ·
I maintainer di solito rispondono entro 1 giorno
-
area:game-bot bug ready-for-agent
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
fil-donadoni/tolaria#4769 ·
I maintainer di solito rispondono entro 1 giorno
-
area:dictation bug P2
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
uttrflow/uttrflow-swift#2539 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
I maintainer di solito rispondono entro 1 giorno
-
documentation internal
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
frostney/GocciaScript#1271 ·
I maintainer di solito rispondono entro 1 giorno