From 670d0db64f980e82eded97ce1bcdfbad38a56542 Mon Sep 17 00:00:00 2001 From: debugtalk Date: Sun, 17 May 2020 11:08:36 +0800 Subject: [PATCH] change: add origin yaml/json testcase path in generated python testcases --- examples/httpbin/basic_test.py | 1 + examples/httpbin/hooks_test.py | 1 + examples/httpbin/load_image_test.py | 1 + examples/httpbin/upload_test.py | 1 + examples/httpbin/validate_test.py | 1 + examples/postman_echo/request_methods/hardcode_test.py | 1 + .../request_methods/request_with_functions_test.py | 1 + .../request_methods/request_with_testcase_reference_test.py | 1 + .../request_methods/request_with_variables_test.py | 1 + .../request_methods/validate_with_functions_test.py | 1 + .../request_methods/validate_with_variables_test.py | 1 + httprunner/ext/make/__init__.py | 4 +++- 12 files changed, 14 insertions(+), 1 deletion(-) diff --git a/examples/httpbin/basic_test.py b/examples/httpbin/basic_test.py index 26862a25..79634dbb 100644 --- a/examples/httpbin/basic_test.py +++ b/examples/httpbin/basic_test.py @@ -1,4 +1,5 @@ # NOTICE: Generated By HttpRunner. DO'NOT EDIT! +# FROM: examples/httpbin/basic.yml from httprunner import HttpRunner, TConfig, TStep diff --git a/examples/httpbin/hooks_test.py b/examples/httpbin/hooks_test.py index b10d450d..84281f9d 100644 --- a/examples/httpbin/hooks_test.py +++ b/examples/httpbin/hooks_test.py @@ -1,4 +1,5 @@ # NOTICE: Generated By HttpRunner. DO'NOT EDIT! +# FROM: examples/httpbin/hooks.yml from httprunner import HttpRunner, TConfig, TStep diff --git a/examples/httpbin/load_image_test.py b/examples/httpbin/load_image_test.py index 6a99f1db..b23759e6 100644 --- a/examples/httpbin/load_image_test.py +++ b/examples/httpbin/load_image_test.py @@ -1,4 +1,5 @@ # NOTICE: Generated By HttpRunner. DO'NOT EDIT! +# FROM: examples/httpbin/load_image.yml from httprunner import HttpRunner, TConfig, TStep diff --git a/examples/httpbin/upload_test.py b/examples/httpbin/upload_test.py index ca418a4e..bef8c0fa 100644 --- a/examples/httpbin/upload_test.py +++ b/examples/httpbin/upload_test.py @@ -1,4 +1,5 @@ # NOTICE: Generated By HttpRunner. DO'NOT EDIT! +# FROM: examples/httpbin/upload.yml from httprunner import HttpRunner, TConfig, TStep diff --git a/examples/httpbin/validate_test.py b/examples/httpbin/validate_test.py index e66796dd..ec88e0a1 100644 --- a/examples/httpbin/validate_test.py +++ b/examples/httpbin/validate_test.py @@ -1,4 +1,5 @@ # NOTICE: Generated By HttpRunner. DO'NOT EDIT! +# FROM: examples/httpbin/validate.yml from httprunner import HttpRunner, TConfig, TStep diff --git a/examples/postman_echo/request_methods/hardcode_test.py b/examples/postman_echo/request_methods/hardcode_test.py index bfbe315b..e60254c4 100644 --- a/examples/postman_echo/request_methods/hardcode_test.py +++ b/examples/postman_echo/request_methods/hardcode_test.py @@ -1,4 +1,5 @@ # NOTICE: Generated By HttpRunner. DO'NOT EDIT! +# FROM: examples/postman_echo/request_methods/hardcode.yml from httprunner import HttpRunner, TConfig, TStep diff --git a/examples/postman_echo/request_methods/request_with_functions_test.py b/examples/postman_echo/request_methods/request_with_functions_test.py index ebe586dd..1933c03a 100644 --- a/examples/postman_echo/request_methods/request_with_functions_test.py +++ b/examples/postman_echo/request_methods/request_with_functions_test.py @@ -1,4 +1,5 @@ # NOTICE: Generated By HttpRunner. DO'NOT EDIT! +# FROM: examples/postman_echo/request_methods/request_with_functions.yml from httprunner import HttpRunner, TConfig, TStep diff --git a/examples/postman_echo/request_methods/request_with_testcase_reference_test.py b/examples/postman_echo/request_methods/request_with_testcase_reference_test.py index 40a59f8f..55b3db9c 100644 --- a/examples/postman_echo/request_methods/request_with_testcase_reference_test.py +++ b/examples/postman_echo/request_methods/request_with_testcase_reference_test.py @@ -1,4 +1,5 @@ # NOTICE: Generated By HttpRunner. DO'NOT EDIT! +# FROM: examples/postman_echo/request_methods/request_with_testcase_reference.yml from httprunner import HttpRunner, TConfig, TStep diff --git a/examples/postman_echo/request_methods/request_with_variables_test.py b/examples/postman_echo/request_methods/request_with_variables_test.py index 4edb4932..12dade62 100644 --- a/examples/postman_echo/request_methods/request_with_variables_test.py +++ b/examples/postman_echo/request_methods/request_with_variables_test.py @@ -1,4 +1,5 @@ # NOTICE: Generated By HttpRunner. DO'NOT EDIT! +# FROM: examples/postman_echo/request_methods/request_with_variables.yml from httprunner import HttpRunner, TConfig, TStep diff --git a/examples/postman_echo/request_methods/validate_with_functions_test.py b/examples/postman_echo/request_methods/validate_with_functions_test.py index 160c1390..a4561d96 100644 --- a/examples/postman_echo/request_methods/validate_with_functions_test.py +++ b/examples/postman_echo/request_methods/validate_with_functions_test.py @@ -1,4 +1,5 @@ # NOTICE: Generated By HttpRunner. DO'NOT EDIT! +# FROM: examples/postman_echo/request_methods/validate_with_functions.yml from httprunner import HttpRunner, TConfig, TStep diff --git a/examples/postman_echo/request_methods/validate_with_variables_test.py b/examples/postman_echo/request_methods/validate_with_variables_test.py index 2bb44eb0..5fe266b9 100644 --- a/examples/postman_echo/request_methods/validate_with_variables_test.py +++ b/examples/postman_echo/request_methods/validate_with_variables_test.py @@ -1,4 +1,5 @@ # NOTICE: Generated By HttpRunner. DO'NOT EDIT! +# FROM: examples/postman_echo/request_methods/validate_with_variables.yml from httprunner import HttpRunner, TConfig, TStep diff --git a/httprunner/ext/make/__init__.py b/httprunner/ext/make/__init__.py index d899488c..4f073b38 100644 --- a/httprunner/ext/make/__init__.py +++ b/httprunner/ext/make/__init__.py @@ -10,6 +10,7 @@ from httprunner.exceptions import TestCaseFormatError from httprunner.loader import load_testcase_file, load_folder_files __TMPL__ = """# NOTICE: Generated By HttpRunner. DO'NOT EDIT! +# FROM: {{ testcase_path }} from httprunner import HttpRunner, TConfig, TStep @@ -64,6 +65,7 @@ def make_testcase(testcase_path: str) -> Union[str, None]: config = testcase["config"] config["path"] = testcase_python_path data = { + "testcase_path": testcase_path, "class_name": f"TestCase{name_in_title_case}", "config": config, "teststeps": testcase["teststeps"], @@ -120,7 +122,7 @@ def init_make_parser(subparsers): """ make testcases: parse command line options and run commands. """ parser = subparsers.add_parser( - "make", help="Convert YAML/JSON testcases to Python unittests.", + "make", help="Convert YAML/JSON testcases to pytest cases.", ) parser.add_argument( "testcase_path", nargs="*", help="Specify YAML/JSON testcase file/folder path"