mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-10 23:12:41 +08:00
change: remove format v2 symbol
This commit is contained in:
@@ -80,7 +80,7 @@ def __extend_with_testcase_ref(raw_testinfo):
|
|||||||
|
|
||||||
# TODO: validate with pydantic
|
# TODO: validate with pydantic
|
||||||
if isinstance(loaded_testcase, dict) and "teststeps" in loaded_testcase:
|
if isinstance(loaded_testcase, dict) and "teststeps" in loaded_testcase:
|
||||||
testcase_dict = load_testcase_v2(loaded_testcase)
|
testcase_dict = load_testcase(loaded_testcase)
|
||||||
else:
|
else:
|
||||||
raise exceptions.FileFormatError(
|
raise exceptions.FileFormatError(
|
||||||
f"Invalid format testcase: {testcase_path}")
|
f"Invalid format testcase: {testcase_path}")
|
||||||
@@ -144,8 +144,8 @@ def load_teststep(raw_testinfo):
|
|||||||
return raw_testinfo
|
return raw_testinfo
|
||||||
|
|
||||||
|
|
||||||
def load_testcase_v2(raw_testcase):
|
def load_testcase(raw_testcase):
|
||||||
""" load testcase in format version 2.
|
""" load testcase.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
raw_testcase (dict): raw testcase content loaded from JSON/YAML file:
|
raw_testcase (dict): raw testcase content loaded from JSON/YAML file:
|
||||||
@@ -174,7 +174,7 @@ def load_testcase_v2(raw_testcase):
|
|||||||
}
|
}
|
||||||
|
|
||||||
"""
|
"""
|
||||||
JsonSchemaChecker.validate_testcase_v2_format(raw_testcase)
|
JsonSchemaChecker.validate_testcase_format(raw_testcase)
|
||||||
raw_teststeps = raw_testcase.pop("teststeps")
|
raw_teststeps = raw_testcase.pop("teststeps")
|
||||||
raw_testcase["teststeps"] = [
|
raw_testcase["teststeps"] = [
|
||||||
load_teststep(teststep)
|
load_teststep(teststep)
|
||||||
@@ -220,7 +220,7 @@ def load_testsuite(raw_testsuite):
|
|||||||
# invalid format
|
# invalid format
|
||||||
raise exceptions.FileFormatError("Invalid testsuite format!")
|
raise exceptions.FileFormatError("Invalid testsuite format!")
|
||||||
|
|
||||||
JsonSchemaChecker.validate_testsuite_v2_format(raw_testsuite)
|
JsonSchemaChecker.validate_testsuite_format(raw_testsuite)
|
||||||
raw_testsuite["testcases"] = {}
|
raw_testsuite["testcases"] = {}
|
||||||
for raw_testcase in raw_testcases:
|
for raw_testcase in raw_testcases:
|
||||||
__extend_with_testcase_ref(raw_testcase)
|
__extend_with_testcase_ref(raw_testcase)
|
||||||
@@ -278,7 +278,7 @@ def load_test_file(path: str) -> dict:
|
|||||||
|
|
||||||
elif "teststeps" in raw_content:
|
elif "teststeps" in raw_content:
|
||||||
# file_type: testcase (format version 2)
|
# file_type: testcase (format version 2)
|
||||||
loaded_content = load_testcase_v2(raw_content)
|
loaded_content = load_testcase(raw_content)
|
||||||
loaded_content["path"] = path
|
loaded_content["path"] = path
|
||||||
loaded_content["type"] = "testcase"
|
loaded_content["type"] = "testcase"
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ from httprunner import exceptions
|
|||||||
schemas_root_dir = os.path.join(os.path.dirname(__file__), "schemas")
|
schemas_root_dir = os.path.join(os.path.dirname(__file__), "schemas")
|
||||||
common_schema_path = os.path.join(schemas_root_dir, "common.schema.json")
|
common_schema_path = os.path.join(schemas_root_dir, "common.schema.json")
|
||||||
api_schema_path = os.path.join(schemas_root_dir, "api.schema.json")
|
api_schema_path = os.path.join(schemas_root_dir, "api.schema.json")
|
||||||
testcase_schema_v2_path = os.path.join(schemas_root_dir, "testcase.schema.v2.json")
|
testcase_schema_path = os.path.join(schemas_root_dir, "testcase.schema.json")
|
||||||
testsuite_schema_v2_path = os.path.join(schemas_root_dir, "testsuite.schema.v2.json")
|
testsuite_schema_path = os.path.join(schemas_root_dir, "testsuite.schema.json")
|
||||||
|
|
||||||
with io.open(api_schema_path, encoding='utf-8') as f:
|
with io.open(api_schema_path, encoding='utf-8') as f:
|
||||||
api_schema = json.load(f)
|
api_schema = json.load(f)
|
||||||
@@ -27,11 +27,11 @@ with io.open(common_schema_path, encoding='utf-8') as f:
|
|||||||
common_schema = json.load(f)
|
common_schema = json.load(f)
|
||||||
resolver = jsonschema.RefResolver(absolute_base_path, common_schema)
|
resolver = jsonschema.RefResolver(absolute_base_path, common_schema)
|
||||||
|
|
||||||
with io.open(testcase_schema_v2_path, encoding='utf-8') as f:
|
with io.open(testcase_schema_path, encoding='utf-8') as f:
|
||||||
testcase_schema_v2 = json.load(f)
|
testcase_schema = json.load(f)
|
||||||
|
|
||||||
with io.open(testsuite_schema_v2_path, encoding='utf-8') as f:
|
with io.open(testsuite_schema_path, encoding='utf-8') as f:
|
||||||
testsuite_schema_v2 = json.load(f)
|
testsuite_schema = json.load(f)
|
||||||
|
|
||||||
|
|
||||||
class JsonSchemaChecker(object):
|
class JsonSchemaChecker(object):
|
||||||
@@ -55,16 +55,16 @@ class JsonSchemaChecker(object):
|
|||||||
return JsonSchemaChecker.validate_format(content, api_schema)
|
return JsonSchemaChecker.validate_format(content, api_schema)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def validate_testcase_v2_format(content):
|
def validate_testcase_format(content):
|
||||||
""" check testcase format v2 if valid
|
""" check testcase format if valid
|
||||||
"""
|
"""
|
||||||
return JsonSchemaChecker.validate_format(content, testcase_schema_v2)
|
return JsonSchemaChecker.validate_format(content, testcase_schema)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def validate_testsuite_v2_format(content):
|
def validate_testsuite_format(content):
|
||||||
""" check testsuite format v2 if valid
|
""" check testsuite format if valid
|
||||||
"""
|
"""
|
||||||
return JsonSchemaChecker.validate_format(content, testsuite_schema_v2)
|
return JsonSchemaChecker.validate_format(content, testsuite_schema)
|
||||||
|
|
||||||
|
|
||||||
def is_test_path(path):
|
def is_test_path(path):
|
||||||
@@ -150,7 +150,7 @@ def is_test_content(data_structure):
|
|||||||
for item in testcases:
|
for item in testcases:
|
||||||
is_testcase = False
|
is_testcase = False
|
||||||
try:
|
try:
|
||||||
JsonSchemaChecker.validate_testcase_v2_format(item)
|
JsonSchemaChecker.validate_testcase_format(item)
|
||||||
is_testcase = True
|
is_testcase = True
|
||||||
except exceptions.FileFormatError:
|
except exceptions.FileFormatError:
|
||||||
pass
|
pass
|
||||||
@@ -169,7 +169,7 @@ def is_test_content(data_structure):
|
|||||||
for item in testsuites:
|
for item in testsuites:
|
||||||
is_testcase = False
|
is_testcase = False
|
||||||
try:
|
try:
|
||||||
JsonSchemaChecker.validate_testsuite_v2_format(item)
|
JsonSchemaChecker.validate_testsuite_format(item)
|
||||||
is_testcase = True
|
is_testcase = True
|
||||||
except exceptions.FileFormatError:
|
except exceptions.FileFormatError:
|
||||||
pass
|
pass
|
||||||
|
|||||||
Reference in New Issue
Block a user