"""Structural notify isolation for the whole test tree.

No test — present or future — may reach the real botmaster/Telegram channel.
Every test process (this one) and every factory subprocess a test spawns
inherits ``os.environ`` (tests build subprocess env as ``{**os.environ, ...}``),
so setting FACTORY_NOTIFY=off here, before any test runs, structurally covers
every send path: unit-level calls into adw_modules.notify AND full ADW
subprocesses spawned by integration tests.
"""

from __future__ import annotations

import os

import pytest


@pytest.fixture(autouse=True, scope="session")
def _factory_notify_off():
    previous = os.environ.get("FACTORY_NOTIFY")
    os.environ["FACTORY_NOTIFY"] = "off"
    try:
        yield
    finally:
        if previous is None:
            os.environ.pop("FACTORY_NOTIFY", None)
        else:
            os.environ["FACTORY_NOTIFY"] = previous
