3
3
import os
4
4
import sys
5
5
6
-
7
6
rootpath = os .path .dirname (os .path .abspath (__file__ ))
8
7
9
8
sys .path .append (os .path .join (rootpath , "pandas/io" ))
10
9
from pandas .io import parsers
11
10
12
-
13
-
14
11
TMP_PATH = "tmp"
15
12
16
13
"""
17
14
To run test, run 'python path/to/test_parsers.py'
18
- """
19
-
20
15
21
- """
22
16
test_read_csv_without_encoding_kwarg returns result of read_csv method.
23
17
- if exception is raised from method, the result returned is the exception.
24
18
"""
19
+
25
20
def test_read_csv_without_encoding_kwarg (file ):
26
21
try :
27
22
result = parsers .read_csv (file )
@@ -31,7 +26,7 @@ def test_read_csv_without_encoding_kwarg(file):
31
26
32
27
33
28
def write_csv_file (filename , data , encoding , delimiter = "," , newline = "" ):
34
- with open (filename , 'w' , newline = newline , encoding = encoding ) as csv_file :
29
+ with open (filename , "w" , newline = newline , encoding = encoding ) as csv_file :
35
30
writer = csv .writer (csv_file , delimiter = delimiter )
36
31
# for row in data:
37
32
writer .writerow (data )
@@ -40,105 +35,106 @@ def write_csv_file(filename, data, encoding, delimiter=",", newline=""):
40
35
41
36
def test ():
42
37
test_results = {}
43
- test_dtypes = ['ascii' ,
44
- 'big5' ,
45
- 'big5hkscs' ,
46
- 'cp037' ,
47
- 'cp273' ,
48
- 'cp424' ,
49
- 'cp437' ,
50
- 'cp500' ,
51
- 'cp720' ,
52
- 'cp737' ,
53
- 'cp775' ,
54
- 'cp850' ,
55
- 'cp852' ,
56
- 'cp855' ,
57
- 'cp856' ,
58
- 'cp857' ,
59
- 'cp858' ,
60
- 'cp860' ,
61
- 'cp861' ,
62
- 'cp862' ,
63
- 'cp863' ,
64
- 'cp864' ,
65
- 'cp865' ,
66
- 'cp866' ,
67
- 'cp869' ,
68
- 'cp874' ,
69
- 'cp875' ,
70
- 'cp932' ,
71
- 'cp949' ,
72
- 'cp950' ,
73
- 'cp1006' ,
74
- 'cp1026' ,
75
- 'cp1125' ,
76
- 'cp1140' ,
77
- 'cp1250' ,
78
- 'cp1251' ,
79
- 'cp1252' ,
80
- 'cp1253' ,
81
- 'cp1254' ,
82
- 'cp1255' ,
83
- 'cp1256' ,
84
- 'cp1257' ,
85
- 'cp1258' ,
86
- 'cp65001' ,
87
- 'euc_jp' ,
88
- 'euc_jis_2004' ,
89
- 'euc_jisx0213' ,
90
- 'euc_kr' ,
91
- 'gb2312' ,
92
- 'gbk' ,
93
- 'gb18030' ,
94
- 'hz' ,
95
- 'iso2022_jp' ,
96
- 'iso2022_jp_1' ,
97
- 'iso2022_jp_2' ,
98
- 'iso2022_jp_2004' ,
99
- 'iso2022_jp_3' ,
100
- 'iso2022_jp_ext' ,
101
- 'iso2022_kr' ,
102
- 'latin_1' ,
103
- 'iso8859_2' ,
104
- 'iso8859_3' ,
105
- 'iso8859_4' ,
106
- 'iso8859_5' ,
107
- 'iso8859_6' ,
108
- 'iso8859_7' ,
109
- 'iso8859_8' ,
110
- 'iso8859_9' ,
111
- 'iso8859_10' ,
112
- 'iso8859_11' ,
113
- 'iso8859_13' ,
114
- 'iso8859_14' ,
115
- 'iso8859_15' ,
116
- 'iso8859_16' ,
117
- 'johab' ,
118
- 'koi8_r' ,
119
- 'koi8_t' ,
120
- 'koi8_u' ,
121
- 'kz1048' ,
122
- 'mac_cyrillic' ,
123
- 'mac_greek' ,
124
- 'mac_iceland' ,
125
- 'mac_latin2' ,
126
- 'mac_roman' ,
127
- 'mac_turkish' ,
128
- 'ptcp154' ,
129
- 'shift_jis' ,
130
- 'shift_jis_2004' ,
131
- 'shift_jisx0213' ,
132
- 'utf_32' ,
133
- 'utf_32_be' ,
134
- 'utf_32_le' ,
135
- 'utf_16' ,
136
- 'utf_16_be' ,
137
- 'utf_16_le' ,
138
- 'utf_7' ,
139
- 'utf_8' ,
140
- 'utf_8_sig'
141
- ]
38
+ test_dtypes = [
39
+ "ascii" ,
40
+ "big5" ,
41
+ "big5hkscs" ,
42
+ "cp037" ,
43
+ "cp273" ,
44
+ "cp424" ,
45
+ "cp437" ,
46
+ "cp500" ,
47
+ "cp720" ,
48
+ "cp737" ,
49
+ "cp775" ,
50
+ "cp850" ,
51
+ "cp852" ,
52
+ "cp855" ,
53
+ "cp856" ,
54
+ "cp857" ,
55
+ "cp858" ,
56
+ "cp860" ,
57
+ "cp861" ,
58
+ "cp862" ,
59
+ "cp863" ,
60
+ "cp864" ,
61
+ "cp865" ,
62
+ "cp866" ,
63
+ "cp869" ,
64
+ "cp874" ,
65
+ "cp875" ,
66
+ "cp932" ,
67
+ "cp949" ,
68
+ "cp950" ,
69
+ "cp1006" ,
70
+ "cp1026" ,
71
+ "cp1125" ,
72
+ "cp1140" ,
73
+ "cp1250" ,
74
+ "cp1251" ,
75
+ "cp1252" ,
76
+ "cp1253" ,
77
+ "cp1254" ,
78
+ "cp1255" ,
79
+ "cp1256" ,
80
+ "cp1257" ,
81
+ "cp1258" ,
82
+ "cp65001" ,
83
+ "euc_jp" ,
84
+ "euc_jis_2004" ,
85
+ "euc_jisx0213" ,
86
+ "euc_kr" ,
87
+ "gb2312" ,
88
+ "gbk" ,
89
+ "gb18030" ,
90
+ "hz" ,
91
+ "iso2022_jp" ,
92
+ "iso2022_jp_1" ,
93
+ "iso2022_jp_2" ,
94
+ "iso2022_jp_2004" ,
95
+ "iso2022_jp_3" ,
96
+ "iso2022_jp_ext" ,
97
+ "iso2022_kr" ,
98
+ "latin_1" ,
99
+ "iso8859_2" ,
100
+ "iso8859_3" ,
101
+ "iso8859_4" ,
102
+ "iso8859_5" ,
103
+ "iso8859_6" ,
104
+ "iso8859_7" ,
105
+ "iso8859_8" ,
106
+ "iso8859_9" ,
107
+ "iso8859_10" ,
108
+ "iso8859_11" ,
109
+ "iso8859_13" ,
110
+ "iso8859_14" ,
111
+ "iso8859_15" ,
112
+ "iso8859_16" ,
113
+ "johab" ,
114
+ "koi8_r" ,
115
+ "koi8_t" ,
116
+ "koi8_u" ,
117
+ "kz1048" ,
118
+ "mac_cyrillic" ,
119
+ "mac_greek" ,
120
+ "mac_iceland" ,
121
+ "mac_latin2" ,
122
+ "mac_roman" ,
123
+ "mac_turkish" ,
124
+ "ptcp154" ,
125
+ "shift_jis" ,
126
+ "shift_jis_2004" ,
127
+ "shift_jisx0213" ,
128
+ "utf_32" ,
129
+ "utf_32_be" ,
130
+ "utf_32_le" ,
131
+ "utf_16" ,
132
+ "utf_16_be" ,
133
+ "utf_16_le" ,
134
+ "utf_7" ,
135
+ "utf_8" ,
136
+ "utf_8_sig" ]
137
+
142
138
data = """
143
139
one,two,three
144
140
1,2,3
@@ -151,6 +147,5 @@ def test():
151
147
152
148
print ("test results: " , test_results )
153
149
154
-
155
- if __name__ == '__main__' :
150
+ if __name__ == "__main__" :
156
151
test ()
0 commit comments