From aa253338b6e217b22675b52057454d83618e0645 Mon Sep 17 00:00:00 2001 From: debugtalk Date: Tue, 17 Dec 2019 21:52:48 +0800 Subject: [PATCH] refactor: dumps request body if it is in json format, display indented json in html report --- docs/CHANGELOG.md | 3 ++- httprunner/report.py | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 492e365c..2763cbb4 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -4,7 +4,8 @@ **Changed** -- refactor: dumps request and response headers/body, display indented json in report +- refactor: dumps request/response headers, display indented json in html report +- refactor: dumps request/response body if it is in json format, display indented json in html report ## 2.4.3 (2019-12-16) diff --git a/httprunner/report.py b/httprunner/report.py index 82bebf3d..afd065e5 100644 --- a/httprunner/report.py +++ b/httprunner/report.py @@ -153,6 +153,12 @@ def __stringify_request(request_data): """ for key, value in request_data.items(): + if key == "body": + try: + value = json.loads(value) + except json.decoder.JSONDecodeError: + pass + if isinstance(value, (list, dict)): value = dumps_json(value)