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) 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): diff --git a/httprunner/response.py b/httprunner/response.py index 7de9bd03..7a130dfb 100644 --- a/httprunner/response.py +++ b/httprunner/response.py @@ -151,6 +151,9 @@ 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: