From 720c02e6abb96374e41c0a7f5e7ee2824fa6f5e1 Mon Sep 17 00:00:00 2001 From: debugtalk Date: Fri, 3 Jan 2020 16:34:12 +0800 Subject: [PATCH] fix #835: UnicodeDecodeError when loading json schema files --- docs/CHANGELOG.md | 7 +++++++ httprunner/loader/check.py | 13 +++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 058025a2..fb86c893 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -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** diff --git a/httprunner/loader/check.py b/httprunner/loader/check.py index ce8ec494..35560d30 100644 --- a/httprunner/loader/check.py +++ b/httprunner/loader/check.py @@ -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)