From d98fbc8da730dabe7a44269fe8b615024cc2c271 Mon Sep 17 00:00:00 2001 From: debugtalk Date: Thu, 9 Apr 2020 11:15:54 +0800 Subject: [PATCH] change: remove format v2 symbol --- httprunner/loader/buildup.py | 12 ++++---- httprunner/loader/check.py | 28 +++++++++---------- ...se.schema.v2.json => testcase.schema.json} | 0 ...e.schema.v2.json => testsuite.schema.json} | 0 4 files changed, 20 insertions(+), 20 deletions(-) rename httprunner/loader/schemas/{testcase.schema.v2.json => testcase.schema.json} (100%) rename httprunner/loader/schemas/{testsuite.schema.v2.json => testsuite.schema.json} (100%) diff --git a/httprunner/loader/buildup.py b/httprunner/loader/buildup.py index b18b6eaf..9652bded 100644 --- a/httprunner/loader/buildup.py +++ b/httprunner/loader/buildup.py @@ -80,7 +80,7 @@ def __extend_with_testcase_ref(raw_testinfo): # TODO: validate with pydantic if isinstance(loaded_testcase, dict) and "teststeps" in loaded_testcase: - testcase_dict = load_testcase_v2(loaded_testcase) + testcase_dict = load_testcase(loaded_testcase) else: raise exceptions.FileFormatError( f"Invalid format testcase: {testcase_path}") @@ -144,8 +144,8 @@ def load_teststep(raw_testinfo): return raw_testinfo -def load_testcase_v2(raw_testcase): - """ load testcase in format version 2. +def load_testcase(raw_testcase): + """ load testcase. Args: 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_testcase["teststeps"] = [ load_teststep(teststep) @@ -220,7 +220,7 @@ def load_testsuite(raw_testsuite): # invalid format raise exceptions.FileFormatError("Invalid testsuite format!") - JsonSchemaChecker.validate_testsuite_v2_format(raw_testsuite) + JsonSchemaChecker.validate_testsuite_format(raw_testsuite) raw_testsuite["testcases"] = {} for raw_testcase in raw_testcases: __extend_with_testcase_ref(raw_testcase) @@ -278,7 +278,7 @@ def load_test_file(path: str) -> dict: elif "teststeps" in raw_content: # 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["type"] = "testcase" diff --git a/httprunner/loader/check.py b/httprunner/loader/check.py index 29730e3a..4e6ce8e8 100644 --- a/httprunner/loader/check.py +++ b/httprunner/loader/check.py @@ -11,8 +11,8 @@ from httprunner import exceptions schemas_root_dir = os.path.join(os.path.dirname(__file__), "schemas") common_schema_path = os.path.join(schemas_root_dir, "common.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") -testsuite_schema_v2_path = os.path.join(schemas_root_dir, "testsuite.schema.v2.json") +testcase_schema_path = os.path.join(schemas_root_dir, "testcase.schema.json") +testsuite_schema_path = os.path.join(schemas_root_dir, "testsuite.schema.json") with io.open(api_schema_path, encoding='utf-8') as 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) resolver = jsonschema.RefResolver(absolute_base_path, common_schema) -with io.open(testcase_schema_v2_path, encoding='utf-8') as f: - testcase_schema_v2 = json.load(f) +with io.open(testcase_schema_path, encoding='utf-8') as f: + testcase_schema = json.load(f) -with io.open(testsuite_schema_v2_path, encoding='utf-8') as f: - testsuite_schema_v2 = json.load(f) +with io.open(testsuite_schema_path, encoding='utf-8') as f: + testsuite_schema = json.load(f) class JsonSchemaChecker(object): @@ -55,16 +55,16 @@ class JsonSchemaChecker(object): return JsonSchemaChecker.validate_format(content, api_schema) @staticmethod - def validate_testcase_v2_format(content): - """ check testcase format v2 if valid + def validate_testcase_format(content): + """ check testcase format if valid """ - return JsonSchemaChecker.validate_format(content, testcase_schema_v2) + return JsonSchemaChecker.validate_format(content, testcase_schema) @staticmethod - def validate_testsuite_v2_format(content): - """ check testsuite format v2 if valid + def validate_testsuite_format(content): + """ 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): @@ -150,7 +150,7 @@ def is_test_content(data_structure): for item in testcases: is_testcase = False try: - JsonSchemaChecker.validate_testcase_v2_format(item) + JsonSchemaChecker.validate_testcase_format(item) is_testcase = True except exceptions.FileFormatError: pass @@ -169,7 +169,7 @@ def is_test_content(data_structure): for item in testsuites: is_testcase = False try: - JsonSchemaChecker.validate_testsuite_v2_format(item) + JsonSchemaChecker.validate_testsuite_format(item) is_testcase = True except exceptions.FileFormatError: pass diff --git a/httprunner/loader/schemas/testcase.schema.v2.json b/httprunner/loader/schemas/testcase.schema.json similarity index 100% rename from httprunner/loader/schemas/testcase.schema.v2.json rename to httprunner/loader/schemas/testcase.schema.json diff --git a/httprunner/loader/schemas/testsuite.schema.v2.json b/httprunner/loader/schemas/testsuite.schema.json similarity index 100% rename from httprunner/loader/schemas/testsuite.schema.v2.json rename to httprunner/loader/schemas/testsuite.schema.json