From ac9664e842fa704c021eb0b3cc44f34e5bd76f09 Mon Sep 17 00:00:00 2001 From: jun Date: Fri, 24 Jul 2020 16:25:41 +0800 Subject: [PATCH] fixed json support and closes #971 --- httprunner/make.py | 4 ++++ httprunner/models.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/httprunner/make.py b/httprunner/make.py index 13b95460..205d8162 100644 --- a/httprunner/make.py +++ b/httprunner/make.py @@ -237,6 +237,10 @@ def make_request_chain_style(request: Dict) -> Text: if "json" in request: req_json = request["json"] + if not isinstance(req_json, Text): + pass + else: + req_json = f'"{req_json}"' request_chain_style += f".with_json({req_json})" if "timeout" in request: diff --git a/httprunner/models.py b/httprunner/models.py index 04fbab23..580e0ffb 100644 --- a/httprunner/models.py +++ b/httprunner/models.py @@ -52,7 +52,7 @@ class TRequest(BaseModel): url: Url params: Dict[Text, Text] = {} headers: Headers = {} - req_json: Union[Dict, List] = Field(None, alias="json") + req_json: Union[Dict, List, Text] = Field(None, alias="json") data: Union[Text, Dict[Text, Any]] = None cookies: Cookies = {} timeout: float = 120