Python · 795 bytes Raw Blame History
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
13 @pytest.fixture(autouse=True)
14 def _offline_and_no_telemetry(monkeypatch: pytest.MonkeyPatch) -> None:
15 """Unit tests never touch the network.
16
17 Any backend test that needs HF should be marked ``@pytest.mark.online``
18 and clear these vars explicitly.
19 """
20 monkeypatch.setenv("HF_HUB_OFFLINE", "1")
21 monkeypatch.setenv("TRANSFORMERS_OFFLINE", "1")
22 monkeypatch.setenv("HF_DATASETS_OFFLINE", "1")
23 monkeypatch.setenv("HF_HUB_DISABLE_TELEMETRY", "1")
24 monkeypatch.setenv("DO_NOT_TRACK", "1")