Skip to content
This repository has been archived by the owner on May 25, 2024. It is now read-only.

Commit

Permalink
format with autopep8
Browse files Browse the repository at this point in the history
  • Loading branch information
helix-xx committed May 6, 2024
1 parent 035aed1 commit 10d7cbb
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions test/file_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import json
import unittest


def test_encode_option(files):
import cjson
import tempfile
Expand All @@ -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
Expand Down Expand Up @@ -45,29 +48,27 @@ 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:
cjson_data = cjson.load(object_hook=d4, fp=f)
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)
Expand All @@ -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)
Expand Down

0 comments on commit 10d7cbb

Please sign in to comment.