From ed9fbdae7707acfb6bba4a0fef29b7dce8d2ffac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Silva?= Date: Mon, 31 Mar 2025 18:07:10 +0100 Subject: [PATCH] Ensure response content is preserved in HTTPError Closes #89 --- tests/test_http_requests.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/test_http_requests.py b/tests/test_http_requests.py index c5961ad..2f477ba 100644 --- a/tests/test_http_requests.py +++ b/tests/test_http_requests.py @@ -7,7 +7,7 @@ import responses from requests import HTTPError, Session -from tests.conftest import DEFAULT_TOKEN +from tests.data.test_defaults import DEFAULT_TOKEN from todoist_api_python.endpoints import BASE_URL, TASKS_ENDPOINT from todoist_api_python.http_requests import delete, get, post @@ -42,12 +42,15 @@ def test_get_raise_for_status() -> None: responses.add( responses.GET, DEFAULT_URL, + json="", status=500, ) - with pytest.raises(HTTPError): + with pytest.raises(HTTPError) as error_info: get(Session(), DEFAULT_URL, DEFAULT_TOKEN) + assert error_info.value.response.content == b'""' + @responses.activate def test_post_with_data(default_task_response: dict[str, Any]) -> None: