diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 36c7461a..97dd8cd0 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,6 +1,6 @@ # Release History -## 3.0.6 (2020-05-25) +## 3.0.6 (2020-05-27) **Added** @@ -9,6 +9,7 @@ **Fixed** - fix: ensure converted python file in utf-8 encoding +- fix: duplicate running referenced testcase ## 3.0.5 (2020-05-22) diff --git a/examples/postman_echo/debugtalk.py b/examples/postman_echo/debugtalk.py index d0502409..af8b22eb 100644 --- a/examples/postman_echo/debugtalk.py +++ b/examples/postman_echo/debugtalk.py @@ -10,6 +10,4 @@ def sum_two(m, n): def get_variables(): - return { - "foo1": "session_bar1" - } + return {"foo1": "session_bar1"} diff --git a/examples/postman_echo/request_methods/demo_testsuite_yml/request_with_testcase_reference_test.py b/examples/postman_echo/request_methods/demo_testsuite_yml/request_with_testcase_reference_test.py index c3755910..bf82fd58 100644 --- a/examples/postman_echo/request_methods/demo_testsuite_yml/request_with_testcase_reference_test.py +++ b/examples/postman_echo/request_methods/demo_testsuite_yml/request_with_testcase_reference_test.py @@ -9,7 +9,7 @@ sys.path.insert(0, os.getcwd()) from httprunner import HttpRunner, TConfig, TStep from examples.postman_echo.request_methods.request_with_functions_test import ( - TestCaseRequestWithFunctions, + TestCaseRequestWithFunctions as RequestWithFunctions, ) @@ -29,7 +29,7 @@ class TestCaseRequestWithTestcaseReference(HttpRunner): **{ "name": "request with functions", "variables": {"foo1": "override_bar1"}, - "testcase": TestCaseRequestWithFunctions, + "testcase": RequestWithFunctions, } ), ] 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 70f3139c..213fc746 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 @@ -9,7 +9,7 @@ sys.path.insert(0, os.getcwd()) from httprunner import HttpRunner, TConfig, TStep from examples.postman_echo.request_methods.request_with_functions_test import ( - TestCaseRequestWithFunctions, + TestCaseRequestWithFunctions as RequestWithFunctions, ) @@ -29,7 +29,7 @@ class TestCaseRequestWithTestcaseReference(HttpRunner): **{ "name": "request with functions", "variables": {"foo1": "override_bar1"}, - "testcase": TestCaseRequestWithFunctions, + "testcase": RequestWithFunctions, } ), ] diff --git a/httprunner/ext/make/__init__.py b/httprunner/ext/make/__init__.py index 11133489..dcfa3ade 100644 --- a/httprunner/ext/make/__init__.py +++ b/httprunner/ext/make/__init__.py @@ -95,9 +95,8 @@ def convert_testcase_path(testcase_path: Text) -> Tuple[Text, Text]: # convert title case, e.g. request_with_variables => RequestWithVariables name_in_title_case = file_name.title().replace("_", "") - testcase_cls_name = f"TestCase{name_in_title_case}" - return testcase_python_path, testcase_cls_name + return testcase_python_path, name_in_title_case def __format_pytest_with_black(python_paths: List[Text]) -> NoReturn: @@ -163,11 +162,13 @@ def __make_testcase(testcase: Dict, dir_path: Text = None) -> NoReturn: ref_testcase_python_path = ref_testcase_python_path[len(os.getcwd()) + 1 :] ref_module_name, _ = os.path.splitext(ref_testcase_python_path) ref_module_name = ref_module_name.replace(os.sep, ".") - imports_list.append(f"from {ref_module_name} import {ref_testcase_cls_name}") + imports_list.append( + f"from {ref_module_name} import TestCase{ref_testcase_cls_name} as {ref_testcase_cls_name}" + ) data = { "testcase_path": __ensure_cwd_relative(testcase_path), - "class_name": testcase_cls_name, + "class_name": f"TestCase{testcase_cls_name}", "config": config, "teststeps": teststeps, "imports_list": imports_list,