@@ -26,7 +26,7 @@ def test_to_csv_with_single_column(self):
26
26
"""
27
27
with tm .ensure_clean ("test.csv" ) as path :
28
28
df1 .to_csv (path , header = None , index = None )
29
- with open (path , "r" ) as f :
29
+ with open (path ) as f :
30
30
assert f .read () == expected1
31
31
32
32
df2 = DataFrame ([1 , None ])
@@ -36,7 +36,7 @@ def test_to_csv_with_single_column(self):
36
36
"""
37
37
with tm .ensure_clean ("test.csv" ) as path :
38
38
df2 .to_csv (path , header = None , index = None )
39
- with open (path , "r" ) as f :
39
+ with open (path ) as f :
40
40
assert f .read () == expected2
41
41
42
42
def test_to_csv_defualt_encoding (self ):
@@ -58,7 +58,7 @@ def test_to_csv_quotechar(self):
58
58
59
59
with tm .ensure_clean ("test.csv" ) as path :
60
60
df .to_csv (path , quoting = 1 ) # 1=QUOTE_ALL
61
- with open (path , "r" ) as f :
61
+ with open (path ) as f :
62
62
assert f .read () == expected
63
63
64
64
expected = """\
@@ -69,7 +69,7 @@ def test_to_csv_quotechar(self):
69
69
70
70
with tm .ensure_clean ("test.csv" ) as path :
71
71
df .to_csv (path , quoting = 1 , quotechar = "$" )
72
- with open (path , "r" ) as f :
72
+ with open (path ) as f :
73
73
assert f .read () == expected
74
74
75
75
with tm .ensure_clean ("test.csv" ) as path :
@@ -86,7 +86,7 @@ def test_to_csv_doublequote(self):
86
86
87
87
with tm .ensure_clean ("test.csv" ) as path :
88
88
df .to_csv (path , quoting = 1 , doublequote = True ) # QUOTE_ALL
89
- with open (path , "r" ) as f :
89
+ with open (path ) as f :
90
90
assert f .read () == expected
91
91
92
92
from _csv import Error
@@ -105,7 +105,7 @@ def test_to_csv_escapechar(self):
105
105
106
106
with tm .ensure_clean ("test.csv" ) as path : # QUOTE_ALL
107
107
df .to_csv (path , quoting = 1 , doublequote = False , escapechar = "\\ " )
108
- with open (path , "r" ) as f :
108
+ with open (path ) as f :
109
109
assert f .read () == expected
110
110
111
111
df = DataFrame ({"col" : ["a,a" , ",bb," ]})
@@ -117,7 +117,7 @@ def test_to_csv_escapechar(self):
117
117
118
118
with tm .ensure_clean ("test.csv" ) as path :
119
119
df .to_csv (path , quoting = 3 , escapechar = "\\ " ) # QUOTE_NONE
120
- with open (path , "r" ) as f :
120
+ with open (path ) as f :
121
121
assert f .read () == expected
122
122
123
123
def test_csv_to_string (self ):
@@ -342,7 +342,7 @@ def test_to_csv_string_array_ascii(self):
342
342
"""
343
343
with tm .ensure_clean ("str_test.csv" ) as path :
344
344
df .to_csv (path , encoding = "ascii" )
345
- with open (path , "r" ) as f :
345
+ with open (path ) as f :
346
346
assert f .read () == expected_ascii
347
347
348
348
def test_to_csv_string_array_utf8 (self ):
@@ -356,7 +356,7 @@ def test_to_csv_string_array_utf8(self):
356
356
"""
357
357
with tm .ensure_clean ("unicode_test.csv" ) as path :
358
358
df .to_csv (path , encoding = "utf-8" )
359
- with open (path , "r" ) as f :
359
+ with open (path ) as f :
360
360
assert f .read () == expected_utf8
361
361
362
362
def test_to_csv_string_with_lf (self ):
@@ -467,7 +467,7 @@ def test_to_csv_write_to_open_file(self):
467
467
with open (path , "w" ) as f :
468
468
f .write ("manual header\n " )
469
469
df .to_csv (f , header = None , index = None )
470
- with open (path , "r" ) as f :
470
+ with open (path ) as f :
471
471
assert f .read () == expected
472
472
473
473
def test_to_csv_write_to_open_file_with_newline_py3 (self ):
0 commit comments