@@ -110,13 +110,10 @@ def test_types_to_csv() -> None:
110
110
111
111
def test_types_to_csv_when_path_passed () -> None :
112
112
df = pd .DataFrame (data = {"col1" : [1 , 2 ], "col2" : [3 , 4 ]})
113
- path : Path = Path ("./dummy_path.txt" )
114
- try :
115
- assert not path .exists ()
113
+ with ensure_clean () as file :
114
+ path = Path (file )
116
115
df .to_csv (path )
117
116
df5 : pd .DataFrame = pd .read_csv (path )
118
- finally :
119
- path .unlink ()
120
117
121
118
122
119
def test_types_copy () -> None :
@@ -788,16 +785,17 @@ def test_to_markdown() -> None:
788
785
def test_types_to_feather () -> None :
789
786
pytest .importorskip ("pyarrow" )
790
787
df = pd .DataFrame (data = {"col1" : [1 , 1 , 2 ], "col2" : [3 , 4 , 5 ]})
791
- df .to_feather ("dummy_path" )
792
- # kwargs for pyarrow.feather.write_feather added in 1.1.0 https://pandas.pydata.org/docs/whatsnew/v1.1.0.html
793
- df .to_feather ("dummy_path" , compression = "zstd" , compression_level = 3 , chunksize = 2 )
794
-
795
- # to_feather has been able to accept a buffer since pandas 1.0.0
796
- # See https://pandas.pydata.org/docs/whatsnew/v1.0.0.html
797
- # Docstring and type were updated in 1.2.0.
798
- # https://github.com/pandas-dev/pandas/pull/35408
799
788
with ensure_clean () as path :
800
789
df .to_feather (path )
790
+ # kwargs for pyarrow.feather.write_feather added in 1.1.0 https://pandas.pydata.org/docs/whatsnew/v1.1.0.html
791
+ df .to_feather (path , compression = "zstd" , compression_level = 3 , chunksize = 2 )
792
+
793
+ # to_feather has been able to accept a buffer since pandas 1.0.0
794
+ # See https://pandas.pydata.org/docs/whatsnew/v1.0.0.html
795
+ # Docstring and type were updated in 1.2.0.
796
+ # https://github.com/pandas-dev/pandas/pull/35408
797
+ with open (path , mode = "wb" ) as file :
798
+ df .to_feather (file )
801
799
802
800
803
801
# compare() method added in 1.1.0 https://pandas.pydata.org/docs/whatsnew/v1.1.0.html
0 commit comments