From f6c4018e9c659b42ad68149f075b851fe75cc3af Mon Sep 17 00:00:00 2001 From: Tomas Repel Date: Thu, 14 Mar 2024 09:45:18 +0100 Subject: [PATCH] Improve extract_response to return None for empty content only --- testsuite/utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/testsuite/utils.py b/testsuite/utils.py index 6b340212..7576d34d 100644 --- a/testsuite/utils.py +++ b/testsuite/utils.py @@ -40,7 +40,7 @@ def generate_tail(tail=5): def randomize(name, tail=5): - "To avoid conflicts returns modified name with random sufffix" + "To avoid conflicts returns modified name with random suffix" return f"{name}-{generate_tail(tail)}" @@ -125,8 +125,8 @@ def extract_response(response, header="Simple", key="data"): :return: Extracted value """ - # Returning None for non-200 responses because the content of such responses might not be a valid JSON - if response.status_code != 200: + # Returning None if content is empty, this typically happens for non-200 responses + if len(response.content) == 0: return weakget(None) return weakget(json.loads(response.json()["headers"][header]))[key]