Fix hub error test construction for huggingface_hub 1.x for PR #6872

huggingface_hub 1.x makes HfHubHTTPError's response argument required and
reads only .headers and .request from it, while 0.x defaults it to None.
Pass a small stub response so the test constructs the error on both,
verified against 0.36.2 and the 1.22.0 wheel.
This commit is contained in:
Daniel Han 2026-07-04 23:36:40 +00:00
commit ee61c7b650

View file

@ -197,9 +197,12 @@ def test_resolve_specs_maps_hub_error_to_valueerror(tmp_path, monkeypatch):
from huggingface_hub.errors import RepositoryNotFoundError
def _boom(spec_id, weight, **kw):
# response is optional in huggingface_hub 0.x but required in 1.x; both only
# read .headers / .request, so a stub keeps the test working on either.
raise RepositoryNotFoundError(
"404 Client Error. Repository Not Found for url: "
"https://huggingface.co/api/models/nope/nope (Request ID: abc)"
"https://huggingface.co/api/models/nope/nope (Request ID: abc)",
response = types.SimpleNamespace(headers = {}, request = None),
)
monkeypatch.setattr(dl, "resolve_one", _boom)