fix #835: UnicodeDecodeError when loading json schema files

This commit is contained in:
debugtalk
2020-01-03 16:34:12 +08:00
parent 3bac9c301f
commit 720c02e6ab
2 changed files with 14 additions and 6 deletions

View File

@@ -1,5 +1,12 @@
# Release History
## 2.5.4 (2020-01-03)
**Fixed**
- fix #835: UnicodeDecodeError when loading json schema files
## 2.5.3 (2020-01-03)
**Fixed**

View File

@@ -1,3 +1,4 @@
import io
import json
import os
import platform
@@ -14,10 +15,10 @@ testcase_schema_v2_path = os.path.join(schemas_root_dir, "testcase.schema.v2.jso
testsuite_schema_v1_path = os.path.join(schemas_root_dir, "testsuite.schema.v1.json")
testsuite_schema_v2_path = os.path.join(schemas_root_dir, "testsuite.schema.v2.json")
with open(api_schema_path) as f:
with io.open(api_schema_path, encoding='utf-8') as f:
api_schema = json.load(f)
with open(common_schema_path) as f:
with io.open(common_schema_path, encoding='utf-8') as f:
if platform.system() == "Windows":
absolute_base_path = 'file:///' + os.path.abspath(schemas_root_dir).replace("\\", "/") + '/'
else:
@@ -27,16 +28,16 @@ with open(common_schema_path) as f:
common_schema = json.load(f)
resolver = jsonschema.RefResolver(absolute_base_path, common_schema)
with open(testcase_schema_v1_path) as f:
with io.open(testcase_schema_v1_path, encoding='utf-8') as f:
testcase_schema_v1 = json.load(f)
with open(testcase_schema_v2_path) as f:
with io.open(testcase_schema_v2_path, encoding='utf-8') as f:
testcase_schema_v2 = json.load(f)
with open(testsuite_schema_v1_path) as f:
with io.open(testsuite_schema_v1_path, encoding='utf-8') as f:
testsuite_schema_v1 = json.load(f)
with open(testsuite_schema_v2_path) as f:
with io.open(testsuite_schema_v2_path, encoding='utf-8') as f:
testsuite_schema_v2 = json.load(f)