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:
parent
639d4061af
commit
ee61c7b650
1 changed files with 4 additions and 1 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue