| 1 | """Shared test fixtures. |
| 2 | |
| 3 | Keep the default fast-test environment offline and deterministic so unit |
| 4 | tests stay below ~1 s per file. Integration tests override these via |
| 5 | their own ``conftest`` when they need network access. |
| 6 | """ |
| 7 | |
| 8 | from __future__ import annotations |
| 9 | |
| 10 | import pytest |
| 11 | |
| 12 | # Import the probes package once so every shipped probe registers itself |
| 13 | # with the central registry. Tests that exercise build_probe("delta_kl", |
| 14 | # …) rely on this. |
| 15 | import dlm_sway.probes # noqa: F401 |
| 16 | |
| 17 | |
| 18 | @pytest.fixture(autouse=True) |
| 19 | def _offline_and_no_telemetry(monkeypatch: pytest.MonkeyPatch) -> None: |
| 20 | """Unit tests never touch the network. |
| 21 | |
| 22 | Any backend test that needs HF should be marked ``@pytest.mark.online`` |
| 23 | and clear these vars explicitly. |
| 24 | """ |
| 25 | monkeypatch.setenv("HF_HUB_OFFLINE", "1") |
| 26 | monkeypatch.setenv("TRANSFORMERS_OFFLINE", "1") |
| 27 | monkeypatch.setenv("HF_DATASETS_OFFLINE", "1") |
| 28 | monkeypatch.setenv("HF_HUB_DISABLE_TELEMETRY", "1") |
| 29 | monkeypatch.setenv("DO_NOT_TRACK", "1") |