update: httprunner make v4

This commit is contained in:
buyuxiang
2022-05-26 16:04:46 +08:00
parent d288d672f8
commit ecd61c815f
10 changed files with 95 additions and 219 deletions

View File

@@ -11,8 +11,8 @@ from httprunner import __version__, exceptions
from httprunner.compat import (
convert_variables,
ensure_path_sep,
ensure_testcase_v3,
ensure_testcase_v3_api,
ensure_testcase_v4,
ensure_testcase_v4_api,
)
from httprunner.loader import (
convert_relative_project_root_dir,
@@ -332,8 +332,8 @@ def make_teststep_chain_style(teststep: Dict) -> Text:
def make_testcase(testcase: Dict, dir_path: Text = None) -> Text:
"""convert valid testcase dict to pytest file path"""
# ensure compatibility with testcase format v2
testcase = ensure_testcase_v3(testcase)
# ensure compatibility with testcase format v2/v3
testcase = ensure_testcase_v4(testcase)
# validate testcase format
load_testcase(testcase)
@@ -373,9 +373,9 @@ def make_testcase(testcase: Dict, dir_path: Text = None) -> Text:
if not isinstance(test_content, Dict):
raise exceptions.TestCaseFormatError(f"Invalid teststep: {teststep}")
# api in v2 format, convert to v3 testcase
# api in v2/v3 format, convert to v4 testcase
if "request" in test_content and "name" in test_content:
test_content = ensure_testcase_v3_api(test_content)
test_content = ensure_testcase_v4_api(test_content)
test_content.setdefault("config", {})["path"] = ref_testcase_path
ref_testcase_python_abs_path = make_testcase(test_content)
@@ -473,9 +473,9 @@ def __make(tests_path: Text):
)
continue
# api in v2 format, convert to v3 testcase
# api in v2/v3 format, convert to v4 testcase
if "request" in test_content and "name" in test_content:
test_content = ensure_testcase_v3_api(test_content)
test_content = ensure_testcase_v4_api(test_content)
if "config" not in test_content:
logger.warning(