From bf09483ecf7b0bf56343816706f0c2f3f04b86cf Mon Sep 17 00:00:00 2001 From: debugtalk Date: Thu, 17 Jan 2019 13:38:33 +0800 Subject: [PATCH 1/6] bugfix: override current teststep variables with former testcase output variables --- httprunner/runner.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/httprunner/runner.py b/httprunner/runner.py index 3b5ca787..32fc6572 100644 --- a/httprunner/runner.py +++ b/httprunner/runner.py @@ -291,6 +291,13 @@ class Runner(object): tests = testcase_dict.get("teststeps", []) for index, test_dict in enumerate(tests): + + # override current teststep variables with former testcase output variables + former_output_variables = self.session_context.test_variables_mapping + if former_output_variables: + test_dict.setdefault("variables", {}) + test_dict["variables"].update(former_output_variables) + try: test_runner.run_test(test_dict) except Exception: From 17138dff983de83418bfd50deb1726523787a66f Mon Sep 17 00:00:00 2001 From: debugtalk Date: Tue, 8 Jan 2019 20:52:04 +0800 Subject: [PATCH 2/6] update unittest --- tests/test_parser.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_parser.py b/tests/test_parser.py index c039f141..628343b8 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -348,13 +348,13 @@ class TestParser(unittest.TestCase): def test_substitute_variables(self): content = { 'request': { - 'url': '/api/users/$uid', + 'url': '/api/users/$uid?id=$id', 'headers': {'token': '$token'} } } - variables_mapping = {"$uid": 1000} + variables_mapping = {"$uid": 1000, "$id": 2} substituted_data = parser.substitute_variables(content, variables_mapping) - self.assertEqual(substituted_data["request"]["url"], "/api/users/1000") + self.assertEqual(substituted_data["request"]["url"], "/api/users/1000?id=2") self.assertEqual(substituted_data["request"]["headers"], {'token': '$token'}) def test_parse_parameters_raw_list(self): From 7b6922817c23aadfd97ff7b8f9ae1540841d77db Mon Sep 17 00:00:00 2001 From: debugtalk Date: Wed, 16 Jan 2019 17:47:44 +0800 Subject: [PATCH 3/6] bugfix: make compatible with testcase name is empty --- httprunner/__about__.py | 2 +- httprunner/parser.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/httprunner/__about__.py b/httprunner/__about__.py index 8cfb52d4..774f7c60 100644 --- a/httprunner/__about__.py +++ b/httprunner/__about__.py @@ -1,7 +1,7 @@ __title__ = 'HttpRunner' __description__ = 'One-stop solution for HTTP(S) testing.' __url__ = 'https://github.com/HttpRunner/HttpRunner' -__version__ = '2.0.0' +__version__ = '2.0.1' __author__ = 'debugtalk' __author_email__ = 'mail@debugtalk.com' __license__ = 'Apache-2.0' diff --git a/httprunner/parser.py b/httprunner/parser.py index 27c80ee7..f4b82ff8 100644 --- a/httprunner/parser.py +++ b/httprunner/parser.py @@ -733,8 +733,12 @@ def _extend_with_testcase(test_dict, testcase_def_dict): test_verify = test_dict.pop("verify", True) testcase_def_dict["config"].setdefault("verify", test_verify) + # override name + test_name = test_dict.pop("name") or testcase_def_dict["config"].pop("name") or "Undefined name" + # override testcase config name, output, etc. testcase_def_dict["config"].update(test_dict) + testcase_def_dict["config"]["name"] = test_name test_dict.clear() test_dict.update(testcase_def_dict) From d3c3732516765fafe21933824c57bae231da876b Mon Sep 17 00:00:00 2001 From: debugtalk Date: Thu, 17 Jan 2019 18:40:46 +0800 Subject: [PATCH 4/6] bugfix: skip undefined variable when parsing string content --- httprunner/parser.py | 3 ++- tests/test_parser.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/httprunner/parser.py b/httprunner/parser.py index f4b82ff8..cd033299 100644 --- a/httprunner/parser.py +++ b/httprunner/parser.py @@ -503,7 +503,8 @@ def parse_string_variables(content, variables_mapping, functions_mapping): parsed_variable_value = parse_data( variable_value, variables_mapping, - functions_mapping + functions_mapping, + raise_if_variable_not_found=False ) # TODO: replace variable label from $var to {{var}} diff --git a/tests/test_parser.py b/tests/test_parser.py index 628343b8..153086fa 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -700,7 +700,7 @@ class TestParser(unittest.TestCase): self.assertEqual(test_dict["variables"]["num4"], "${sum_two($num0, 5)}") self.assertEqual( test_dict["request"]["url"], - "https://httprunner.org/api1/?num1=$num1&num2=$num2&num3=$num3&num4=$num4" + "https://httprunner.org/api1/?num1=3&num2=6&num3=10&num4=${sum_two($num0, 5)}" ) def test_parse_tests_base_url_teststep_empty(self): From 51bb4b108c21ea6b284aa644069a58ed6a456294 Mon Sep 17 00:00:00 2001 From: debugtalk Date: Fri, 18 Jan 2019 12:47:55 +0800 Subject: [PATCH 5/6] bugfix: add request method in report --- httprunner/client.py | 1 + 1 file changed, 1 insertion(+) diff --git a/httprunner/client.py b/httprunner/client.py index a31031c2..3de5c47f 100644 --- a/httprunner/client.py +++ b/httprunner/client.py @@ -82,6 +82,7 @@ class HttpSession(requests.Session): # record actual request info req_resp_dict["request"]["url"] = resp_obj.request.url + req_resp_dict["request"]["method"] = resp_obj.request.method req_resp_dict["request"]["headers"] = dict(resp_obj.request.headers) request_body = resp_obj.request.body From 8f59643ca96bb41627d2db5a088bcb4e99c7bf85 Mon Sep 17 00:00:00 2001 From: debugtalk Date: Fri, 18 Jan 2019 19:06:42 +0800 Subject: [PATCH 6/6] add Release History --- HISTORY.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 HISTORY.md diff --git a/HISTORY.md b/HISTORY.md new file mode 100644 index 00000000..cff5d7a3 --- /dev/null +++ b/HISTORY.md @@ -0,0 +1,19 @@ +# Release History + +## 2.0.1 (2019.01.18) + +Bugfixes: + +- override current teststep variables with former testcase output variables; +- make compatible with testcase name is empty; +- skip undefined variable when parsing string content; +- add request method in report. + +## 2.0.0 (2019.01.01) + +- Massive Refactor and Simplification +- Redesign testcase structure +- Module pipline +- Start Semantic Versioning +- Switch to Apache 2.0 license +- Change logo