@@ -104,45 +104,45 @@ def test_expand_and_restore(self):
104104class TestConvertJSON (unittest .TestCase ):
105105
106106 def test_convert_expand (self ):
107- fin = io .BytesIO (u'{"a":{"b":3}}\n {"a":{"c":4}}\n ' . encode ( 'utf-8' ) )
108- fout = io .BytesIO ()
107+ fin = io .StringIO (u'{"a":{"b":3}}\n {"a":{"c":4}}\n ' )
108+ fout = io .StringIO ()
109109
110110 convert_json (fin , fout , expand )
111111
112- self .assertEqual (b '{"a.b": 3}\n {"a.c": 4}\n ' , fout .getvalue ())
112+ self .assertEqual ('{"a.b": 3}\n {"a.c": 4}\n ' , fout .getvalue ())
113113
114114 fin .close ()
115115 fout .close ()
116116
117117 def test_convert_with_unicode (self ):
118- fin = io .BytesIO (u'{"河流":{"长度":3}}\n {"河流":{"名字":"长江"}}\n ' . encode ( 'utf-8' ) )
119- fout = io .BytesIO ()
118+ fin = io .StringIO (u'{"河流":{"长度":3}}\n {"河流":{"名字":"长江"}}\n ' )
119+ fout = io .StringIO ()
120120
121121 convert_json (fin , fout , expand )
122122
123- self .assertEqual (u'{"河流.长度": 3}\n {"河流.名字": "长江"}\n ' . encode ( 'utf-8' ) , fout .getvalue ())
123+ self .assertEqual (u'{"河流.长度": 3}\n {"河流.名字": "长江"}\n ' , fout .getvalue ())
124124
125125 fin .close ()
126126 fout .close ()
127127
128128 def test_convert_restore (self ):
129- fin = io .BytesIO (u'{"a.b": 3}\n {"a.c": 4}\n ' . encode ( 'utf-8' ) )
130- fout = io .BytesIO ()
129+ fin = io .StringIO (u'{"a.b": 3}\n {"a.c": 4}\n ' )
130+ fout = io .StringIO ()
131131
132132 convert_json (fin , fout , restore )
133133
134- self .assertEqual (b '{"a": {"b": 3}}\n {"a": {"c": 4}}\n ' , fout .getvalue ())
134+ self .assertEqual ('{"a": {"b": 3}}\n {"a": {"c": 4}}\n ' , fout .getvalue ())
135135
136136 fin .close ()
137137 fout .close ()
138138
139139 def test_convert_expand_json_array (self ):
140- fin = io .BytesIO (u'[{"a":{"b":3}},{"a":{"c":4}}]' . encode ( 'utf-8' ) )
141- fout = io .BytesIO ()
140+ fin = io .StringIO (u'[{"a":{"b":3}},{"a":{"c":4}}]' )
141+ fout = io .StringIO ()
142142
143143 convert_json (fin , fout , expand , json_array = True )
144144
145- self .assertEqual (b '{"a.b": 3}\n {"a.c": 4}\n ' , fout .getvalue ())
145+ self .assertEqual ('{"a.b": 3}\n {"a.c": 4}\n ' , fout .getvalue ())
146146
147147 fin .close ()
148148 fout .close ()
0 commit comments