"""Executable contracts for the mandatory CPU/offline pytest policy.""" from __future__ import annotations import os import socket import pytest def test_unmarked_tests_run_with_offline_hugging_face_policy(): assert os.environ["HF_DATASETS_OFFLINE"] == "1" assert os.environ["HF_HUB_DISABLE_TELEMETRY"] == "1" assert os.environ["HF_HUB_OFFLINE"] == "1" assert os.environ["TRANSFORMERS_OFFLINE"] == "1" def test_unmarked_tests_cannot_open_network_connections(): with pytest.raises(RuntimeError, match="unmarked tests may not access the network"): socket.create_connection(("example.invalid", 443))