diff --git a/src/backend/tests/test_vision_upload_limits.py b/src/backend/tests/test_vision_upload_limits.py index 894efc7..eed4b93 100644 --- a/src/backend/tests/test_vision_upload_limits.py +++ b/src/backend/tests/test_vision_upload_limits.py @@ -21,6 +21,22 @@ from src.backend.models.orm.vision import VisionReferenceImage, VisionResult from src.backend.tests.conftest import auth_headers, create_test_recipe +@pytest.fixture(autouse=True) +def redirect_uploads(monkeypatch, tmp_path): + """Keep the reference image this file stores out of the real repo tree. + + The same guard `test_vision_reference.py` carries: without it, the test that + proves a jpeg is stored with its own extension leaves a real file under + `uploads/vision/reference/`, so every suite run dirties the working tree. + + `settings.upload_path` is `parents[2] / self.upload_dir`, and pathlib + replaces the left operand of `/` when the right one is absolute - so + redirecting the bare `upload_dir` setting is enough to redirect the + resolved path too. + """ + monkeypatch.setattr(settings, "upload_dir", str(tmp_path)) + + def a_png() -> bytes: buffer = io.BytesIO() Image.new("L", (64, 64), color=0).save(buffer, format="PNG")