Spaces:
Runtime error

aureon-os / tests /support /mcp_plugin.py
GaryLeckey's picture
Publish Aureon OS from source ca6be206f108a2474a8cb38faf9ad3ae836e1479 (files 1-250/16781) (#1)
56c0d82
Raw History Blame Contribute Delete
1.49 kB
"""Pytest fixtures that keep the Space import guard inside MCP tests.
Loaded from the repository conftest via pytest_plugins so tests/conftest.py
does not shadow ``from conftest import``.
"""
from __future__ import annotations
import os
import pytest
from tests.support import mcp_isolation
def _mcp_module(request: pytest.FixtureRequest) -> bool:
return mcp_isolation.is_mcp_test_module(request.module.__name__)
@pytest.fixture(scope="module", autouse=True)
def _mcp_public_imports(request: pytest.FixtureRequest) -> None:
if not _mcp_module(request):
try:
yield
finally:
# Non-MCP modules (e.g. test_aureon_public_stage2/stage34/queen_stage8)
# can still import aureon_public and install PinnedAureonFinder on
# sys.meta_path. Drop it at module end so later in-process aureon
# imports are not blob-checked against the pin.
# Also drops the _BlockTrading finder at module end, for test isolation only; not a guard removal outside tests.
mcp_isolation.teardown_guard_leaks()
return
env_before = dict(os.environ)
mcp_isolation.load_public_test_bindings(request.module)
try:
yield
finally:
mcp_isolation.teardown_guard_leaks()
os.environ.clear()
os.environ.update(env_before)
@pytest.fixture(scope="session", autouse=True)
def _mcp_guard_session_teardown() -> None:
yield
mcp_isolation.teardown_guard_leaks()