From 094c0c62685347b3562a8e5c1b866eb33e89fff1 Mon Sep 17 00:00:00 2001 From: Guillaume Giffard Date: Wed, 30 Oct 2024 14:53:03 +0100 Subject: [PATCH] - fix str(HTTPStatus) == "HTTPStatus.OK" instead of "200" on python3.10 and older - ease debugging --- aiven/client/client.py | 2 +- tests/test_client.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/aiven/client/client.py b/aiven/client/client.py index 26eff86..70f4ca1 100644 --- a/aiven/client/client.py +++ b/aiven/client/client.py @@ -48,7 +48,7 @@ class Error(Exception): """Request error""" def __init__(self, response: Response, status: int = 520) -> None: - Exception.__init__(self, response.text) + Exception.__init__(self, f"{response.text}, status({type(status)})={str(status)}") self.response = response self.status = status diff --git a/tests/test_client.py b/tests/test_client.py index 203af75..c656a12 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -18,12 +18,12 @@ class MockResponse: def __init__( self, - status_code: int, + status_code: int | HTTPStatus, json_data: dict[str, Any] | None = None, headers: dict[str, str] | None = None, content: bytes | None = None, ): - self.status_code = status_code + self.status_code = status_code.value if isinstance(status_code, HTTPStatus) else status_code self.json_data = json_data if content is not None: self.content = content