From ae41de39266e92e34726c3ce621ed06917df7bc8 Mon Sep 17 00:00:00 2001 From: xucong053 <43516634+xucong053@users.noreply.github.com> Date: Tue, 13 Jul 2021 20:28:46 +0800 Subject: [PATCH 1/4] fix: _search_jmespath add expr verificaion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _search_jmespath():input-->output before:"success"-->None after:"success"-->"success" --- httprunner/response.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/httprunner/response.py b/httprunner/response.py index 7de9bd03..e6784149 100644 --- a/httprunner/response.py +++ b/httprunner/response.py @@ -151,6 +151,8 @@ class ResponseObject(object): "cookies": self.cookies, "body": self.body, } + if not expr.startswith(tuple(resp_obj_meta.keys())): + return expr try: check_value = jmespath.search(expr, resp_obj_meta) except JMESPathError as ex: From c453da3d5f9dfddc8c8cef3f20d50125124e50e9 Mon Sep 17 00:00:00 2001 From: xucong053 <43516634+xucong053@users.noreply.github.com> Date: Tue, 13 Jul 2021 21:40:41 +0800 Subject: [PATCH 2/4] add a line break --- httprunner/response.py | 1 + 1 file changed, 1 insertion(+) diff --git a/httprunner/response.py b/httprunner/response.py index e6784149..7a130dfb 100644 --- a/httprunner/response.py +++ b/httprunner/response.py @@ -153,6 +153,7 @@ class ResponseObject(object): } if not expr.startswith(tuple(resp_obj_meta.keys())): return expr + try: check_value = jmespath.search(expr, resp_obj_meta) except JMESPathError as ex: From aba5cf67bdcb250a7219ac14cafc5fddad49bae6 Mon Sep 17 00:00:00 2001 From: xucong053 <43516634+xucong053@users.noreply.github.com> Date: Tue, 13 Jul 2021 21:54:20 +0800 Subject: [PATCH 3/4] =?UTF-8?q?fix=EF=BC=9Aresolved=20list=20read=20error?= =?UTF-8?q?=20caused=20by=20Pydantic.BaseModel=20#1079?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- httprunner/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httprunner/models.py b/httprunner/models.py index 3016b040..c4b60955 100644 --- a/httprunner/models.py +++ b/httprunner/models.py @@ -124,7 +124,7 @@ class RequestData(BaseModel): url: Url headers: Headers = {} cookies: Cookies = {} - body: Union[Text, bytes, Dict, List, None] = {} + body: Union[Text, bytes, List, Dict, None] = {} class ResponseData(BaseModel): @@ -133,7 +133,7 @@ class ResponseData(BaseModel): cookies: Cookies encoding: Union[Text, None] = None content_type: Text - body: Union[Text, bytes, Dict, List] + body: Union[Text, bytes, List, Dict] class ReqRespData(BaseModel): From 1dbc5158d936b88fd532cc1e895611e85815de0f Mon Sep 17 00:00:00 2001 From: xucong053 <43516634+xucong053@users.noreply.github.com> Date: Tue, 13 Jul 2021 22:02:27 +0800 Subject: [PATCH 4/4] =?UTF-8?q?fix=EF=BC=9Aadd=20list2json=20for=20better?= =?UTF-8?q?=20display?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- httprunner/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httprunner/client.py b/httprunner/client.py index 1832ed95..71f228f9 100644 --- a/httprunner/client.py +++ b/httprunner/client.py @@ -33,7 +33,7 @@ def get_req_resp_record(resp_obj: Response) -> ReqRespData: def log_print(req_or_resp, r_type): msg = f"\n================== {r_type} details ==================\n" for key, value in req_or_resp.dict().items(): - if isinstance(value, dict): + if isinstance(value, dict) or isinstance(value, list): value = json.dumps(value, indent=4, ensure_ascii=False) msg += "{:<8} : {}\n".format(key, value)