"""Shared pytest fixtures for the Gitea-Tools test suite.""" import sys import pytest sys.path.insert(0, str(__import__("pathlib").Path(__file__).resolve().parent.parent)) @pytest.fixture(autouse=True) def _reset_mutation_authority(monkeypatch): """Isolate the in-process mutation authority between tests (#199). The mutation-authority gate stays LIVE in every test — this fixture only clears the per-process record and the session profile lock so one test's seeded authority (or an intentionally mismatched one) cannot leak into the next test. It must never replace verify_mutation_authority with a no-op: individual tests that need a specific authority state set it up explicitly. """ monkeypatch.delenv("GITEA_SESSION_PROFILE_LOCK", raising=False) try: import mcp_server except Exception: yield return monkeypatch.setattr(mcp_server, "_MUTATION_AUTHORITY", None) monkeypatch.setattr(mcp_server, "_IDENTITY_CACHE", {}) monkeypatch.setattr(mcp_server, "_REVIEW_DECISION_LOCK", None) yield