1414 date_range ,
1515 read_hdf ,
1616)
17- from pandas .tests .io .pytables .common import ensure_clean_store
1817
1918from pandas .io .pytables import (
2019 Term ,
2423pytestmark = [pytest .mark .single_cpu ]
2524
2625
27- def test_pass_spec_to_storer (setup_path ):
26+ def test_pass_spec_to_storer (tmp_path , setup_path ):
2827 df = DataFrame (
2928 1.1 * np .arange (120 ).reshape ((30 , 4 )),
3029 columns = Index (list ("ABCD" ), dtype = object ),
3130 index = Index ([f"i-{ i } " for i in range (30 )], dtype = object ),
3231 )
3332
34- with ensure_clean_store ( setup_path ) as store :
33+ with HDFStore ( tmp_path / setup_path ) as store :
3534 store .put ("df" , df )
3635 msg = (
3736 "cannot pass a column specification when reading a Fixed format "
@@ -47,19 +46,19 @@ def test_pass_spec_to_storer(setup_path):
4746 store .select ("df" , where = ["columns=A" ])
4847
4948
50- def test_table_index_incompatible_dtypes (setup_path ):
49+ def test_table_index_incompatible_dtypes (tmp_path , setup_path ):
5150 df1 = DataFrame ({"a" : [1 , 2 , 3 ]})
5251 df2 = DataFrame ({"a" : [4 , 5 , 6 ]}, index = date_range ("1/1/2000" , periods = 3 ))
5352
54- with ensure_clean_store ( setup_path ) as store :
53+ with HDFStore ( tmp_path / setup_path ) as store :
5554 store .put ("frame" , df1 , format = "table" )
5655 msg = re .escape ("incompatible kind in col [integer - datetime64[ns]]" )
5756 with pytest .raises (TypeError , match = msg ):
5857 store .put ("frame" , df2 , format = "table" , append = True )
5958
6059
61- def test_unimplemented_dtypes_table_columns (setup_path ):
62- with ensure_clean_store ( setup_path ) as store :
60+ def test_unimplemented_dtypes_table_columns (tmp_path , setup_path ):
61+ with HDFStore ( tmp_path / setup_path ) as store :
6362 dtypes = [("date" , datetime .date (2001 , 1 , 2 ))]
6463
6564 # currently not supported dtypes ####
@@ -85,7 +84,7 @@ def test_unimplemented_dtypes_table_columns(setup_path):
8584 df ["datetime1" ] = datetime .date (2001 , 1 , 2 )
8685 df = df ._consolidate ()
8786
88- with ensure_clean_store ( setup_path ) as store :
87+ with HDFStore ( tmp_path / setup_path ) as store :
8988 # this fails because we have a date in the object block......
9089 msg = "|" .join (
9190 [
@@ -101,7 +100,7 @@ def test_unimplemented_dtypes_table_columns(setup_path):
101100
102101
103102def test_invalid_terms (tmp_path , setup_path ):
104- with ensure_clean_store ( setup_path ) as store :
103+ with HDFStore ( tmp_path / setup_path ) as store :
105104 df = DataFrame (
106105 np .random .default_rng (2 ).standard_normal ((10 , 4 )),
107106 columns = Index (list ("ABCD" ), dtype = object ),
@@ -162,14 +161,14 @@ def test_invalid_terms(tmp_path, setup_path):
162161 read_hdf (path , "dfq" , where = "A>0 or C>0" )
163162
164163
165- def test_append_with_diff_col_name_types_raises_value_error (setup_path ):
164+ def test_append_with_diff_col_name_types_raises_value_error (tmp_path , setup_path ):
166165 df = DataFrame (np .random .default_rng (2 ).standard_normal ((10 , 1 )))
167166 df2 = DataFrame ({"a" : np .random .default_rng (2 ).standard_normal (10 )})
168167 df3 = DataFrame ({(1 , 2 ): np .random .default_rng (2 ).standard_normal (10 )})
169168 df4 = DataFrame ({("1" , 2 ): np .random .default_rng (2 ).standard_normal (10 )})
170169 df5 = DataFrame ({("1" , 2 , object ): np .random .default_rng (2 ).standard_normal (10 )})
171170
172- with ensure_clean_store ( setup_path ) as store :
171+ with HDFStore ( tmp_path / setup_path ) as store :
173172 name = "df_diff_valerror"
174173 store .append (name , df )
175174
0 commit comments