Skip to content

Commit

Permalink
Fix tests using httpx errors
Browse files Browse the repository at this point in the history
  - Use base HTTPError class for exception handling in tests

  Tests using the Flash Slowwly API sometimes raise errors different than ReadTimeout
  or ConnectTimeout.
  • Loading branch information
vinisalazar committed Dec 1, 2022
1 parent 51bdd40 commit 7c49ef6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tests/test_erddapy.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def test_erddap_requests_kwargs():

connection.requests_kwargs["timeout"] = timeout_seconds

with pytest.raises((httpx.ReadTimeout, httpx.ConnectTimeout)):
with pytest.raises(httpx.HTTPError):
url = connection.get_download_url()
_ = urlopen(url, requests_kwargs=connection.requests_kwargs)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_url_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_urlopen_requests_kwargs():
slowwly_milliseconds = (timeout_seconds + 1) * 1000
slowwly_url = f"https://flash-the-slow-api.herokuapp.com/delay/{slowwly_milliseconds}/url/{base_url}"

with pytest.raises(httpx.ReadTimeout):
with pytest.raises(httpx.HTTPError):
urlopen(slowwly_url, requests_kwargs={"timeout": timeout_seconds})


Expand Down

0 comments on commit 7c49ef6

Please sign in to comment.