"""Repo-wide test config for tradein-mvp/backend. Registers custom pytest markers so they don't emit PytestUnknownMarkWarning when used (`--strict-markers` is not enabled in pyproject.toml, so an unregistered marker would only warn, not fail — this just keeps output clean and documents intent in one place). Also resets cross-test-file shared rate-limiter state (see fixture docstring below). """ from __future__ import annotations import pytest def pytest_configure(config) -> None: config.addinivalue_line( "markers", "pdf_render: real (non-mocked) WeasyPrint render — needs native " "Pango/cairo/GObject libs, self-skips where unavailable (see " "tests/test_pdf_real_render.py docstring for how to run it for real).", ) @pytest.fixture(autouse=True) def _reset_estimate_rate_limiter() -> None: """`app.api.v1.trade_in._estimate_limiter` (#b2c-antiabuse-2) is a module-level `SlidingWindowLimiter` singleton that accumulates hits across ALL tests hitting POST /estimate within one pytest process (a dozen+ test files build their own FastAPI app around `trade_in_module.router` — see grep for `trade_in_module.router` under tests/). Without a reset, unrelated test files could trip the 429 rate-limit purely from cross-test state leakage (same class of issue `test_support.py::_fresh_rate_limiter` solves locally for `_send_limiter` — this one needs to be global since so many files touch the trade_in router). Lazy import: keeps conftest.py import-light and avoids forcing DATABASE_URL to be set before any test module has had a chance to default it. """ from app.api.v1 import trade_in as trade_in_module from app.core.config import settings from app.core.ratelimit import SlidingWindowLimiter trade_in_module._estimate_limiter = SlidingWindowLimiter( limit=settings.estimate_rate_limit, window_s=settings.estimate_rate_limit_window_s )