def assert_auth(url, *args, headers, **kwargs): assert headers["authorization"] == "Bearer foo" return http_head(url, *args, headers=headers, **kwargs)
def test_http_offline(tmp_path_factory): filename = tmp_path_factory.mktemp("data") / "file.html" with pytest.raises(OfflineModeIsEnabled): http_get("https://huggingface.co", temp_file=filename) with pytest.raises(OfflineModeIsEnabled): http_head("https://huggingface.co")
def test_offline_with_datasets_offline_mode_enabled(): with offline(OfflineSimulationMode.HF_DATASETS_OFFLINE_SET_TO_1): with pytest.raises(ConnectionError): http_head("https://huggingface.co")