zapret-kvn/tests/conftest.py
loop-uh add9f894b1
Some checks failed
Windows project source guards / test (push) Has been cancelled
tests: keep every pytest run off the real report ingest
A targeted local run without ZAPRET_KVN_CLIENT_REPORTS=off sent six app
errors of the dev tree (0.8.101) to production: a test built the real
controller, its reporter became the process-wide app-error sink, and later
tests hit the updater, storage and subscription failure paths. conftest.py
now sets the switch for every pytest run and clears the sink after each test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 05:33:55 -05:00

25 lines
924 B
Python

"""Every pytest run is a test run: nothing it does may reach the real report ingest.
On 2026-11-20 a targeted local run without ZAPRET_KVN_CLIENT_REPORTS=off sent six app errors of the dev tree to
production: a test built the real controller, whose reporter became the process-wide app-error sink, and later
tests in the same process hit the updater, storage and subscription failure paths. The switch is now set here for
every run (tests of the reporter itself pass ``enabled=True`` with a fake opener), and the sink is cleared after
each test so a controller of one test never receives another test's errors.
"""
from __future__ import annotations
import os
import pytest
os.environ["ZAPRET_KVN_CLIENT_REPORTS"] = "off"
@pytest.fixture(autouse=True)
def _no_app_error_sink_between_tests():
yield
from xray_fluent.client_reports import app_errors
app_errors.set_sink(None)
app_errors._early.clear()