@@ -130,19 +130,19 @@ def test_dtype_and_names_error(c_parser_only):
130
130
],
131
131
ids = ["dt64-0" , "dt64-1" , "td64" , f"{ tm .ENDIAN } U8" ],
132
132
)
133
- def test_unsupported_dtype (c_parser_only , match , kwargs ):
133
+ def test_unsupported_dtype (c_parser_only , match , kwargs , tmp_path ):
134
134
parser = c_parser_only
135
135
df = DataFrame (
136
136
np .random .default_rng (2 ).random ((5 , 2 )),
137
137
columns = list ("AB" ),
138
138
index = ["1A" , "1B" , "1C" , "1D" , "1E" ],
139
139
)
140
140
141
- with tm . ensure_clean ( "__unsupported_dtype__.csv" ) as path :
142
- df .to_csv (path )
141
+ path = tmp_path / "__unsupported_dtype__.csv"
142
+ df .to_csv (path )
143
143
144
- with pytest .raises (TypeError , match = match ):
145
- parser .read_csv (path , index_col = 0 , ** kwargs )
144
+ with pytest .raises (TypeError , match = match ):
145
+ parser .read_csv (path , index_col = 0 , ** kwargs )
146
146
147
147
148
148
@td .skip_if_32bit
@@ -563,27 +563,27 @@ def test_file_handles_mmap(c_parser_only, csv1):
563
563
assert not m .closed
564
564
565
565
566
- def test_file_binary_mode (c_parser_only ):
566
+ def test_file_binary_mode (c_parser_only , temp_file ):
567
567
# see gh-23779
568
568
parser = c_parser_only
569
569
expected = DataFrame ([[1 , 2 , 3 ], [4 , 5 , 6 ]])
570
570
571
- with tm . ensure_clean () as path :
572
- with open (path , "w" , encoding = "utf-8" ) as f :
573
- f .write ("1,2,3\n 4,5,6" )
571
+ path = temp_file
572
+ with open (path , "w" , encoding = "utf-8" ) as f :
573
+ f .write ("1,2,3\n 4,5,6" )
574
574
575
- with open (path , "rb" ) as f :
576
- result = parser .read_csv (f , header = None )
577
- tm .assert_frame_equal (result , expected )
575
+ with open (path , "rb" ) as f :
576
+ result = parser .read_csv (f , header = None )
577
+ tm .assert_frame_equal (result , expected )
578
578
579
579
580
- def test_unix_style_breaks (c_parser_only ):
580
+ def test_unix_style_breaks (c_parser_only , temp_file ):
581
581
# GH 11020
582
582
parser = c_parser_only
583
- with tm . ensure_clean () as path :
584
- with open (path , "w" , newline = "\n " , encoding = "utf-8" ) as f :
585
- f .write ("blah\n \n col_1,col_2,col_3\n \n " )
586
- result = parser .read_csv (path , skiprows = 2 , encoding = "utf-8" , engine = "c" )
583
+ path = temp_file
584
+ with open (path , "w" , newline = "\n " , encoding = "utf-8" ) as f :
585
+ f .write ("blah\n \n col_1,col_2,col_3\n \n " )
586
+ result = parser .read_csv (path , skiprows = 2 , encoding = "utf-8" , engine = "c" )
587
587
expected = DataFrame (columns = ["col_1" , "col_2" , "col_3" ])
588
588
tm .assert_frame_equal (result , expected )
589
589
0 commit comments