def with_json(self, json_dict: dict) -> "Statistic":
body = json.dumps(json_dict, sort_keys=True)
actual_body = self.get_current_request().body.decode("utf-8", errors="skip")
try:
actual_json_dict = json.loads(actual_body)
except json.JSONDecodeError:
requested_time = self._current_request_index + 1
self._error_messages.append(f"\nFor the {requested_time} time: with json {body}.\n"
f"But for the {requested_time} time: json was corrupted "
f"{actual_body.__repr__()}.")
return self
actual_body = json.dumps(actual_json_dict, sort_keys=True)
if body != actual_body:
requested_time = self._current_request_index + 1
self._error_messages.append(f"\nFor the {requested_time} time: with json {body}.\n"
f"But for the {requested_time} time: json was {actual_body}.")
return self
评论列表
文章目录