From 5fd247124aaa7b0269d1491982d5f46b732c5247 Mon Sep 17 00:00:00 2001 From: James McKinney <26463+jpmckinney@users.noreply.github.com> Date: Fri, 23 Aug 2024 18:15:24 -0400 Subject: [PATCH] fix: Read bytes to avoid ijson deprecation --- flattentool/json_input.py | 2 +- flattentool/tests/test_json_input.py | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/flattentool/json_input.py b/flattentool/json_input.py index bba3a5e..60e9d36 100644 --- a/flattentool/json_input.py +++ b/flattentool/json_input.py @@ -302,7 +302,7 @@ def __init__( else: path = root_list_path.replace("/", ".") + ".item" - json_file = codecs.open(json_filename, encoding="utf-8") + json_file = codecs.open(json_filename, "rb") self.root_json_list = ijson.items(json_file, path, map_type=OrderedDict) diff --git a/flattentool/tests/test_json_input.py b/flattentool/tests/test_json_input.py index b15b3da..acfbf15 100644 --- a/flattentool/tests/test_json_input.py +++ b/flattentool/tests/test_json_input.py @@ -8,11 +8,7 @@ import pytest -from flattentool.json_input import ( - BadlyFormedJSONError, - BadlyFormedJSONErrorUTF8, - JSONParser, -) +from flattentool.json_input import BadlyFormedJSONError, JSONParser from flattentool.schema import SchemaParser from flattentool.tests.test_schema_parser import object_in_array_example_properties @@ -35,9 +31,6 @@ def test_jsonparser_bad_json_utf8(): name = os.path.join( os.path.dirname(os.path.realpath(__file__)), "fixtures", "bad-utf8.json" ) - # matches against the special error type - with pytest.raises(BadlyFormedJSONErrorUTF8): - JSONParser(json_filename=name) # matches against our base error type with pytest.raises(BadlyFormedJSONError): JSONParser(json_filename=name)