Skip to content

Commit 6053558

Browse files
committed
fix fuck test
1 parent dd0d774 commit 6053558

4 files changed

Lines changed: 17 additions & 5 deletions

File tree

.flake8

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[flake8]
2+
ignore = E501

jsoncsv/jsontool.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# author@alingse
33
# 2016.05.27
44
from __future__ import absolute_import
5+
from __future__ import unicode_literals
56

67
import json
78

@@ -150,4 +151,4 @@ def convert_json(fin, fout, type="expand", separator=".", safe=False):
150151
fout.write(content)
151152
else:
152153
fout.write(content.encode('utf-8'))
153-
fout.write('\n')
154+
fout.write(str('\n'))

tests/test_jsoncsv.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ def test_jsoncsv_expand(self):
1414
runner = CliRunner()
1515
args = ['-e', 'fixture/files/raw.0.json', 'fixture/files/tmp.expand.0.json']
1616
result = runner.invoke(jsoncsv, args=args)
17+
print(result)
1718
assert result.exit_code == 0

tests/test_jsontool.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# coding=utf-8
22
# author@alingse
33
# 2016.08.09
4+
from __future__ import unicode_literals
45

56
import io
67
import unittest
78

9+
from jsoncsv import PY3
810
from jsoncsv.jsontool import expand, restore
911
from jsoncsv.jsontool import is_array
1012
from jsoncsv.jsontool import convert_json
@@ -92,8 +94,11 @@ def test_expand_with_safe(self):
9294
class TestConvertJSON(unittest.TestCase):
9395

9496
def test_convert_expand(self):
95-
fin = io.BytesIO('{"a":{"b":3}}\n{"a":{"c":4}}\n')
96-
fout = io.BytesIO()
97+
fin = io.StringIO('{"a":{"b":3}}\n{"a":{"c":4}}\n')
98+
if PY3:
99+
fout = io.StringIO()
100+
else:
101+
fout = io.BytesIO()
97102

98103
convert_json(fin, fout)
99104

@@ -103,8 +108,11 @@ def test_convert_expand(self):
103108
fout.close()
104109

105110
def test_convert_restore(self):
106-
fin = io.BytesIO('{"a.b": 3}\n{"a.c": 4}\n')
107-
fout = io.BytesIO()
111+
fin = io.StringIO('{"a.b": 3}\n{"a.c": 4}\n')
112+
if PY3:
113+
fout = io.StringIO()
114+
else:
115+
fout = io.BytesIO()
108116

109117
convert_json(fin, fout, type="restore")
110118

0 commit comments

Comments
 (0)