From 8da4afcbc9ece68a20a1bcbbca4b3bbeba41dc30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lennart=20Frid=C3=A9n?= Date: Wed, 20 Mar 2024 09:50:10 +0100 Subject: [PATCH] Prefer capitalised acronyms as per PEP 8 For reference, see https://peps.python.org/pep-0008/#descriptive-naming-styles --- src/requtests/parsed_request.py | 4 ++-- tests/parsed_request_test.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/requtests/parsed_request.py b/src/requtests/parsed_request.py index e7bbcc6..d998da8 100644 --- a/src/requtests/parsed_request.py +++ b/src/requtests/parsed_request.py @@ -4,7 +4,7 @@ from urllib.parse import parse_qs, urlparse -class CannotParseBodyAsJson(RuntimeError): +class CannotParseBodyAsJSON(RuntimeError): def __init__(self, error): super().__init__(error) self.error = error @@ -39,7 +39,7 @@ def json(self) -> Any: try: return json.loads(self.prepared_request.body) except (TypeError, JSONDecodeError) as e: - raise CannotParseBodyAsJson(e) + raise CannotParseBodyAsJSON(e) @property def method(self) -> str: diff --git a/tests/parsed_request_test.py b/tests/parsed_request_test.py index 50d1119..f6b66fb 100644 --- a/tests/parsed_request_test.py +++ b/tests/parsed_request_test.py @@ -2,7 +2,7 @@ import pytest import re from requtests import ParsedRequest -from requtests.parsed_request import CannotParseBodyAsJson +from requtests.parsed_request import CannotParseBodyAsJSON from tests.test_utils import build_request @@ -51,7 +51,7 @@ def test_parsing_a_prepared_request(prepared_request): def test_json_with_an_empty_body(parsed_request): parsed_request.prepared_request.body = None expected_message = "the JSON object must be str, bytes or bytearray, not NoneType" - with pytest.raises(CannotParseBodyAsJson, match=expected_message) as exc_info: + with pytest.raises(CannotParseBodyAsJSON, match=expected_message) as exc_info: parsed_request.json underlying_error = exc_info.value.error assert isinstance(underlying_error, TypeError) @@ -60,7 +60,7 @@ def test_json_with_an_empty_body(parsed_request): def test_json_with_an_invalid_json_body(parsed_request): parsed_request.prepared_request.body = '{"broken": "json' expected_message = re.escape("Unterminated string starting at: line 1 column 12 (char 11)") - with pytest.raises(CannotParseBodyAsJson, match=expected_message) as exc_info: + with pytest.raises(CannotParseBodyAsJSON, match=expected_message) as exc_info: parsed_request.json underlying_error = exc_info.value.error assert isinstance(underlying_error, JSONDecodeError)