mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 02:21:29 +08:00
bugfix: represent unicode literals in html report
This commit is contained in:
@@ -113,12 +113,16 @@ class HttpSession(requests.Session):
|
||||
self.meta_data["request_body"] = response.request.body
|
||||
self.meta_data["status_code"] = response.status_code
|
||||
self.meta_data["response_headers"] = response.headers
|
||||
self.meta_data["response_content"] = response.content
|
||||
|
||||
try:
|
||||
self.meta_data["response_body"] = response.json()
|
||||
except ValueError:
|
||||
self.meta_data["response_body"] = response.content
|
||||
|
||||
msg = "response details:\n"
|
||||
msg += "> status_code: {}\n".format(self.meta_data["status_code"])
|
||||
msg += "> headers: {}\n".format(self.meta_data["response_headers"])
|
||||
msg += "> content: {}".format(self.meta_data["response_content"])
|
||||
msg += "> body: {}".format(self.meta_data["response_body"])
|
||||
logger.log_debug(msg)
|
||||
|
||||
# get the length of the content, but if the argument stream is set to True, we take
|
||||
|
||||
@@ -5,11 +5,12 @@ import os
|
||||
import platform
|
||||
import time
|
||||
import unittest
|
||||
from collections import Iterable
|
||||
from datetime import datetime
|
||||
|
||||
from httprunner import logger
|
||||
from httprunner.__about__ import __version__
|
||||
from httprunner.compat import basestring, bytes, numeric_types
|
||||
from httprunner.compat import basestring, bytes, json, numeric_types
|
||||
from jinja2 import Template
|
||||
from requests.structures import CaseInsensitiveDict
|
||||
|
||||
@@ -62,13 +63,13 @@ def make_json_serializable(raw_json):
|
||||
value = value.decode("utf-8")
|
||||
elif isinstance(value, CaseInsensitiveDict):
|
||||
value = dict(value)
|
||||
elif not isinstance(value, (basestring, numeric_types)):
|
||||
elif not isinstance(value, (basestring, numeric_types, Iterable)):
|
||||
# class instance, e.g. MultipartEncoder()
|
||||
value = repr(value)
|
||||
|
||||
serializable_json[key] = value
|
||||
|
||||
return serializable_json
|
||||
return json.dumps(serializable_json, indent=2, ensure_ascii=False)
|
||||
|
||||
|
||||
class HtmlTestResult(unittest.TextTestResult):
|
||||
|
||||
@@ -188,7 +188,7 @@
|
||||
<div class="popup">
|
||||
<h2>Request and Response data</h2>
|
||||
<a class="close" href="#">×</a>
|
||||
<div class="content"><pre>{{ record.meta_data | tojson(indent=2) | safe }}</pre></div>
|
||||
<div class="content"><pre>{{ record.meta_data | safe }}</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user