fix: duplicate running referenced testcase

This commit is contained in:
debugtalk
2020-05-27 11:20:38 +08:00
parent e278d67886
commit add70330d2
5 changed files with 12 additions and 12 deletions

View File

@@ -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)

View File

@@ -10,6 +10,4 @@ def sum_two(m, n):
def get_variables():
return {
"foo1": "session_bar1"
}
return {"foo1": "session_bar1"}

View File

@@ -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,
}
),
]

View File

@@ -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,
}
),
]

View File

@@ -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,