From 7c49ef654d99ff95fa844ef9ca70b44884fb118d Mon Sep 17 00:00:00 2001 From: Vini Salazar <17276653+vinisalazar@users.noreply.github.com> Date: Thu, 1 Dec 2022 11:47:58 +1100 Subject: [PATCH] Fix tests using httpx errors - Use base HTTPError class for exception handling in tests Tests using the Flash Slowwly API sometimes raise errors different than ReadTimeout or ConnectTimeout. --- tests/test_erddapy.py | 2 +- tests/test_url_handling.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_erddapy.py b/tests/test_erddapy.py index cf9d4365..617aa916 100644 --- a/tests/test_erddapy.py +++ b/tests/test_erddapy.py @@ -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) diff --git a/tests/test_url_handling.py b/tests/test_url_handling.py index 793b3309..95dc938d 100644 --- a/tests/test_url_handling.py +++ b/tests/test_url_handling.py @@ -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})