Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure response content is preserved in HTTPError #180

Merged
merged 1 commit into from
Mar 31, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions tests/test_http_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -42,12 +42,15 @@ def test_get_raise_for_status() -> None:
responses.add(
responses.GET,
DEFAULT_URL,
json="<error description>",
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'"<error description>"'


@responses.activate
def test_post_with_data(default_task_response: dict[str, Any]) -> None:
Expand Down