Skip to content

Commit

Permalink
Bugfix: Update message regarding connection issues to the HF hub (#1141)
Browse files Browse the repository at this point in the history
(cherry picked from commit 6621c0f)
  • Loading branch information
stancld authored and Borda committed Jul 22, 2022
1 parent c9faed4 commit af8b327
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tests/text/helpers.py
Expand Up @@ -440,15 +440,15 @@ def skip_on_connection_issues(reason: str = "Unable to load checkpoints from Hug
The tests run normally if no connection issue arises, and they're marked as skipped otherwise.
"""
_error_msg_start = "We couldn't connect to"
_error_msg_starts = ["We couldn't connect to", "Connection error", "Can't load"]

def test_decorator(function: Callable, *args: Any, **kwargs: Any) -> Optional[Callable]:
@wraps(function)
def run_test(*args: Any, **kwargs: Any) -> Optional[Any]:
try:
return function(*args, **kwargs)
except OSError as ex:
if _error_msg_start not in str(ex):
except (OSError, ValueError) as ex:
if all(msg_start not in str(ex) for msg_start in _error_msg_starts):
raise ex
pytest.skip(reason)

Expand Down

0 comments on commit af8b327

Please sign in to comment.