diff --git a/httprunner/__about__.py b/httprunner/__about__.py index e7674ab8..c146d7ef 100644 --- a/httprunner/__about__.py +++ b/httprunner/__about__.py @@ -1,7 +1,7 @@ __title__ = 'HttpRunner' __description__ = 'One-stop solution for HTTP(S) testing.' __url__ = 'https://github.com/HttpRunner/HttpRunner' -__version__ = '1.5.8' +__version__ = '1.5.9' __author__ = 'debugtalk' __author_email__ = 'mail@debugtalk.com' __license__ = 'MIT' diff --git a/httprunner/report.py b/httprunner/report.py index cfdb8fea..35dcae3f 100644 --- a/httprunner/report.py +++ b/httprunner/report.py @@ -120,9 +120,7 @@ def stringify_data(meta_data, request_or_response): } """ headers = meta_data[request_or_response]["headers"] - request_or_response_dict = meta_data[request_or_response] - response_content_type = meta_data["response"]["content_type"] for key, value in request_or_response_dict.items(): @@ -135,11 +133,11 @@ def stringify_data(meta_data, request_or_response): if not encoding or encoding == "None": encoding = "utf-8" - if request_or_response == "response" and key == "content" and "image" in response_content_type: + if request_or_response == "response" and key == "content" \ + and "image" in meta_data["response"]["content_type"]: # display image - meta_data["response"]["content_type"] = "image" value = "data:{};base64,{}".format( - response_content_type, + meta_data["response"]["content_type"], b64encode(value).decode(encoding) ) else: diff --git a/httprunner/templates/report_template.html b/httprunner/templates/report_template.html index 03ba45f2..03356661 100644 --- a/httprunner/templates/report_template.html +++ b/httprunner/templates/report_template.html @@ -272,20 +272,20 @@
| {{key}} |
{% if key == "headers" %}
- {% for header_key, header_value in record.meta_data.request.headers.items() %}
+ {% for header_key, header_value in record.meta_data.response.headers.items() %}
{{ header_key }}: {{ header_value }}
{% endfor %}
- {% elif key == "text" %}
- {% if value == "image" %}
+ {% elif key == "content" %}
+ {% if "image" in record.meta_data.response.content_type %}
{{ record.meta_data.response.text | e }}
diff --git a/tests/test_response.py b/tests/test_response.py
index 06d78649..a28cb699 100644
--- a/tests/test_response.py
+++ b/tests/test_response.py
@@ -135,7 +135,7 @@ class TestResponse(ApiServerUnittest):
]
extract_binds_dict = resp_obj.extract_response(extract_binds_list)
self.assertGreater(extract_binds_dict["resp_elapsed_microseconds"], 1000)
- self.assertEqual(extract_binds_dict["resp_elapsed_seconds"], 0)
+ self.assertLess(extract_binds_dict["resp_elapsed_seconds"], 3)
self.assertEqual(extract_binds_dict["resp_elapsed_days"], 0)
self.assertGreater(extract_binds_dict["resp_elapsed_total_seconds"], 0)
|
|---|