Przeglądaj źródła

Post work PR #2956

-----

Give each test worker its own scratch folder in the #3025 and #3029 tests (issue #3025)

Both modules wrote into one shared folder under settings.base_dir and deleted
it after every test. Under xdist, one worker's cleanup removed files another
worker was still serving, so tests failed at random with a 404. The folder name
now includes the process ID.
maziggy 22 godzin temu
rodzic
commit
89c4ac5583

Plik diff jest za duży
+ 0 - 1
CHANGELOG.md


+ 6 - 1
backend/tests/integration/test_media_token_3025.py

@@ -18,6 +18,7 @@ its header-authenticated siblings.
 
 from __future__ import annotations
 
+import os
 import shutil
 from pathlib import Path
 
@@ -108,7 +109,11 @@ async def _mint_camera_token(async_client: AsyncClient, jwt: str) -> str:
 # The routes resolve thumbnails relative to ``settings.base_dir``, so the
 # fixtures have to write there rather than into tmp_path. Keep them in one
 # subdirectory and delete it after every test so a run leaves the tree clean.
-_THUMB_DIR = "test_thumbs_3025"
+#
+# ``base_dir`` is shared by every xdist worker, so the subdirectory is per
+# process: with one shared name, a worker's teardown deleted the thumbnails
+# another worker's test was about to serve, and that test got a 404.
+_THUMB_DIR = f"test_thumbs_3025_{os.getpid()}"
 
 
 @pytest.fixture(autouse=True)

+ 5 - 2
backend/tests/integration/test_slicer_token_reuse_3029.py

@@ -27,6 +27,7 @@ route's own token check ever ran.
 
 from __future__ import annotations
 
+import os
 import shutil
 from datetime import datetime, timedelta, timezone
 from pathlib import Path
@@ -38,8 +39,10 @@ pytestmark = [pytest.mark.asyncio, pytest.mark.integration]
 
 # Same reasoning as #3025's fixtures: the routes resolve paths relative to
 # ``settings.base_dir``, which under test is the project root, so everything
-# goes in one subdirectory that is removed after each test.
-_FILE_DIR = "test_files_3029"
+# goes in one subdirectory that is removed after each test. Per process for the
+# same reason too: every xdist worker shares ``base_dir``, and with one shared
+# name a worker's teardown deleted files another worker's test was serving.
+_FILE_DIR = f"test_files_3029_{os.getpid()}"
 
 
 @pytest.fixture(autouse=True)

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików