From 10d7cbb20de06ca960741c818a12fb4b078ac587 Mon Sep 17 00:00:00 2001 From: helix_xx <630824252@qq.com> Date: Mon, 6 May 2024 21:44:12 +0800 Subject: [PATCH] format with autopep8 --- test/file_test.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/test/file_test.py b/test/file_test.py index 108aef5..a50b08b 100644 --- a/test/file_test.py +++ b/test/file_test.py @@ -3,6 +3,7 @@ import json import unittest + def test_encode_option(files): import cjson import tempfile @@ -12,12 +13,14 @@ def test_encode_option(files): with tempfile.NamedTemporaryFile(mode="w+", encoding='ascii') as f: cjson.dump(json_data, f) + def test_decode_option(files): import cjson for file in files: with open(file, "r", encoding="ascii") as f: cjson_data = cjson.load(f) + class TestJsonFileIO(unittest.TestCase): def _check_obj_same(self, a, b): from test_utils import check_obj_same @@ -45,7 +48,7 @@ def d4(obj): if "a" in obj: return A(obj["a"]) return obj - + for file in self.file_path: # test parse keyword with open(file, "r+", encoding="utf-8") as f: @@ -53,21 +56,19 @@ def d4(obj): f.seek(0) json_data = json.load(f) self._check_obj_same(cjson_data, json_data) - - + with open(file, "r+", encoding="utf-8") as f: cjson_data = cjson.load(f) f.seek(0) json_data = json.load(f) self._check_obj_same(cjson_data, json_data) - - + def test_json_dump(self): import cjson import tempfile - + for data in self.datas: - # test parse keyword + # test parse keyword with tempfile.NamedTemporaryFile(mode="w+", encoding='utf-8') as f: cjson.dump(skipkeys=False, fp=f, obj=data) f.seek(0) @@ -77,7 +78,7 @@ def test_json_dump(self): f.seek(0) json_data = json.load(f) self._check_obj_same(cjson_data, json_data) - + with tempfile.NamedTemporaryFile(mode="w+", encoding='utf-8') as f: cjson.dump(data, f) f.seek(0)