33# 2018.03.29
44
55import unittest
6+ from io import open
67
78from jsoncsv .dumptool import DumpCSV
89from jsoncsv .dumptool import DumpXLS
@@ -13,39 +14,39 @@ class TestDumpTool(unittest.TestCase):
1314
1415 # FIXME (使用虚拟文件)
1516 def test_dumpexcel_csv (self ):
16- fin = open ('./fixture/files/expand.1.json' , 'r' )
17+ fin = open ('./fixture/files/expand.1.json' , 'r' , encoding = 'utf-8' )
1718 fout = open ('./fixture/files/tmp.output.1.csv' , 'wb' )
1819
1920 dump_excel (fin , fout , DumpCSV )
2021 fin .close ()
2122 fout .close ()
2223
23- output = open ('./fixture/files/output.1.csv' , 'r' )
24- fout = open ('./fixture/files/tmp.output.1.csv' , 'r' )
24+ output = open ('./fixture/files/output.1.csv' , 'r' , encoding = 'utf-8' )
25+ fout = open ('./fixture/files/tmp.output.1.csv' , 'r' , encoding = 'utf-8' )
2526
2627 self .assertEqual (output .read (), fout .read ())
2728
2829 output .close ()
2930 fout .close ()
3031
3132 def test_dumpexcel_csv_with_sort (self ):
32- fin = open ('./fixture/files/expand.1.json' , 'r' )
33+ fin = open ('./fixture/files/expand.1.json' , 'r' , encoding = 'utf-8' )
3334 fout = open ('./fixture/files/tmp.output.1.sort.csv' , 'wb' )
3435
3536 dump_excel (fin , fout , DumpCSV , sort_type = True )
3637 fin .close ()
3738 fout .close ()
3839
39- output = open ('./fixture/files/output.1.sort.csv' , 'r' )
40- fout = open ('./fixture/files/tmp.output.1.sort.csv' , 'r' )
40+ output = open ('./fixture/files/output.1.sort.csv' , 'r' , encoding = 'utf-8' )
41+ fout = open ('./fixture/files/tmp.output.1.sort.csv' , 'r' , encoding = 'utf-8' )
4142
4243 self .assertEqual (output .read (), fout .read ())
4344
4445 output .close ()
4546 fout .close ()
4647
4748 def test_dumpcexcel_xls (self ):
48- fin = open ('./fixture/files/expand.1.json' , 'r' )
49+ fin = open ('./fixture/files/expand.1.json' , 'r' , encoding = 'utf-8' )
4950 fout = open ('./fixture/files/tmp.output.1.xls' , 'wb' )
5051
5152 dump_excel (fin , fout , DumpXLS )
@@ -54,7 +55,7 @@ def test_dumpcexcel_xls(self):
5455 fout .close ()
5556
5657 def test_dump_csv_with_non_ascii (self ):
57- fin = open ('./fixture/files/expand.2.json' , 'r' )
58+ fin = open ('./fixture/files/expand.2.json' , 'r' , encoding = 'utf-8' )
5859 fout = open ('./fixture/files/tmp.output.2.csv' , 'wb' )
5960
6061 dump_excel (fin , fout , DumpCSV )
@@ -63,7 +64,7 @@ def test_dump_csv_with_non_ascii(self):
6364 fout .close ()
6465
6566 def test_dump_xls_with_non_ascii (self ):
66- fin = open ('./fixture/files/expand.2.json' , 'r' )
67+ fin = open ('./fixture/files/expand.2.json' , 'r' , encoding = 'utf-8' )
6768 fout = open ('./fixture/files/tmp.output.2.xls' , 'wb' )
6869
6970 dump_excel (fin , fout , DumpXLS )
0 commit comments