diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 3e6f92b6..a193c99f 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -6,7 +6,7 @@ - feat: add json schema validation for api - feat: add json schema validation for testcase v2 -- feat: add json schema validation for testsuite +- feat: add json schema validation for testsuite v2 **Changed** diff --git a/httprunner/loader/check.py b/httprunner/loader/check.py index f8feff26..853d1d59 100644 --- a/httprunner/loader/check.py +++ b/httprunner/loader/check.py @@ -10,7 +10,7 @@ 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_path = os.path.join(schemas_root_dir, "testsuite.schema.json") +testsuite_schema_v2_path = os.path.join(schemas_root_dir, "testsuite.schema.v2.json") with open(api_schema_path) as f: api_schema = json.load(f) @@ -22,8 +22,8 @@ with open(common_schema_path) as f: with open(testcase_schema_v2_path) as f: testcase_schema_v2 = json.load(f) -with open(testsuite_schema_path) as f: - testsuite_schema = json.load(f) +with open(testsuite_schema_v2_path) as f: + testsuite_schema_v2 = json.load(f) class JsonSchemaChecker(object): @@ -42,7 +42,7 @@ class JsonSchemaChecker(object): @staticmethod def validate_testsuite_format(content): try: - jsonschema.validate(content, testsuite_schema, resolver=resolver) + jsonschema.validate(content, testsuite_schema_v2, resolver=resolver) except jsonschema.exceptions.ValidationError as ex: logger.log_error(str(ex)) raise exceptions.FileFormatError diff --git a/httprunner/loader/schemas/testsuite.schema.json b/httprunner/loader/schemas/testsuite.schema.v2.json similarity index 94% rename from httprunner/loader/schemas/testsuite.schema.json rename to httprunner/loader/schemas/testsuite.schema.v2.json index 6d021123..f4dd1f5a 100644 --- a/httprunner/loader/schemas/testsuite.schema.json +++ b/httprunner/loader/schemas/testsuite.schema.v2.json @@ -35,7 +35,7 @@ "type": "array", "minItems": 1, "items": { - "$ref": "testsuite.schema.json#/definitions/testcase" + "$ref": "testsuite.schema.v2.json#/definitions/testcase" } } },