statistic.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:py_fake_server 作者: Telichkin 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号