From 52e95f8317b202050c9c127b6ea4b7ced93fffcf Mon Sep 17 00:00:00 2001 From: mhorky Date: Tue, 19 Dec 2023 14:12:25 +0100 Subject: [PATCH] Fix an error in debug logging of cloud-what The `requests.PreparedRequest` may not have any `.body` attribute set. This happens when unit tests are run, for example. In that case the test would crash. --- src/cloud_what/_base_provider.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cloud_what/_base_provider.py b/src/cloud_what/_base_provider.py index 6b0379d49a..304faf2925 100644 --- a/src/cloud_what/_base_provider.py +++ b/src/cloud_what/_base_provider.py @@ -366,7 +366,7 @@ def _debug_print_http_request(request: requests.PreparedRequest) -> None: print(colorize("Request headers:", COLOR.GREEN)) print(colorize(f"{request.headers}", COLOR.BLUE)) - if os.environ.get("SUBMAN_DEBUG_PRINT_REQUEST_BODY", "") and request.body is not None: + if os.environ.get("SUBMAN_DEBUG_PRINT_REQUEST_BODY", "") and hasattr(request, "body"): print(colorize("Request body:", COLOR.GREEN)) print(colorize(f"{request.body}", COLOR.YELLOW))