11# coding=utf-8
22# author@alingse
33# 2018.03.29
4-
4+ import io
55import unittest
6- from io import open
76
87from jsoncsv .dumptool import DumpCSV
98from jsoncsv .dumptool import DumpXLS
@@ -14,58 +13,58 @@ class TestDumpTool(unittest.TestCase):
1413
1514 # FIXME (使用虚拟文件)
1615 def test_dumpexcel_csv (self ):
17- fin = open ('./fixture/files/expand.1.json' , 'r' , encoding = 'utf-8' )
18- fout = open ('./fixture/files/tmp.output.1.csv' , 'wb' )
16+ fin = io . open ('./fixture/files/expand.1.json' , 'r' , encoding = 'utf-8' )
17+ fout = io . open ('./fixture/files/tmp.output.1.csv' , 'wb' )
1918
2019 dump_excel (fin , fout , DumpCSV )
2120 fin .close ()
2221 fout .close ()
2322
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' )
23+ output = io . open ('./fixture/files/output.1.csv' , 'r' , encoding = 'utf-8' )
24+ fout = io . open ('./fixture/files/tmp.output.1.csv' , 'r' , encoding = 'utf-8' )
2625
2726 self .assertEqual (output .read (), fout .read ())
2827
2928 output .close ()
3029 fout .close ()
3130
3231 def test_dumpexcel_csv_with_sort (self ):
33- fin = open ('./fixture/files/expand.1.json' , 'r' , encoding = 'utf-8' )
34- fout = open ('./fixture/files/tmp.output.1.sort.csv' , 'wb' )
32+ fin = io . open ('./fixture/files/expand.1.json' , 'r' , encoding = 'utf-8' )
33+ fout = io . open ('./fixture/files/tmp.output.1.sort.csv' , 'wb' )
3534
3635 dump_excel (fin , fout , DumpCSV , sort_type = True )
3736 fin .close ()
3837 fout .close ()
3938
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' )
39+ output = io . open ('./fixture/files/output.1.sort.csv' , 'r' , encoding = 'utf-8' )
40+ fout = io . open ('./fixture/files/tmp.output.1.sort.csv' , 'r' , encoding = 'utf-8' )
4241
4342 self .assertEqual (output .read (), fout .read ())
4443
4544 output .close ()
4645 fout .close ()
4746
4847 def test_dumpcexcel_xls (self ):
49- fin = open ('./fixture/files/expand.1.json' , 'r' , encoding = 'utf-8' )
50- fout = open ('./fixture/files/tmp.output.1.xls' , 'wb' )
48+ fin = io . open ('./fixture/files/expand.1.json' , 'r' , encoding = 'utf-8' )
49+ fout = io . open ('./fixture/files/tmp.output.1.xls' , 'wb' )
5150
5251 dump_excel (fin , fout , DumpXLS )
5352
5453 fin .close ()
5554 fout .close ()
5655
5756 def test_dump_csv_with_non_ascii (self ):
58- fin = open ('./fixture/files/expand.2.json' , 'r' , encoding = 'utf-8' )
59- fout = open ('./fixture/files/tmp.output.2.csv' , 'wb' )
57+ fin = io . open ('./fixture/files/expand.2.json' , 'r' , encoding = 'utf-8' )
58+ fout = io . open ('./fixture/files/tmp.output.2.csv' , 'wb' )
6059
6160 dump_excel (fin , fout , DumpCSV )
6261
6362 fin .close ()
6463 fout .close ()
6564
6665 def test_dump_xls_with_non_ascii (self ):
67- fin = open ('./fixture/files/expand.2.json' , 'r' , encoding = 'utf-8' )
68- fout = open ('./fixture/files/tmp.output.2.xls' , 'wb' )
66+ fin = io . open ('./fixture/files/expand.2.json' , 'r' , encoding = 'utf-8' )
67+ fout = io . open ('./fixture/files/tmp.output.2.xls' , 'wb' )
6968
7069 dump_excel (fin , fout , DumpXLS )
7170
0 commit comments