"""Shared pytest fixtures for the backend suite.

Added in v0.27.0 (security audit 0026) alongside the new per-IP rate
limiter. The limiters in `app.ratelimit` are process-global singletons,
so their state survives across tests within a run; without a reset, the
accumulated requests from earlier tests exhaust the budget and later
tests see spurious 429s. This autouse fixture gives every test a clean
limiter window.
"""
import pytest

from app import ratelimit


@pytest.fixture(autouse=True)
def _reset_rate_limiters():
    ratelimit._reset_all_for_tests()
    yield
    ratelimit._reset_all_for_tests()
