diff --git a/pandas/tests/io/pytables/test_complex.py b/pandas/tests/io/pytables/test_complex.py index 80e7664d1969e..e92e2164f36ff 100644 --- a/pandas/tests/io/pytables/test_complex.py +++ b/pandas/tests/io/pytables/test_complex.py @@ -4,10 +4,10 @@ import pandas as pd from pandas import ( DataFrame, + HDFStore, Series, ) import pandas._testing as tm -from pandas.tests.io.pytables.common import ensure_clean_store from pandas.io.pytables import read_hdf @@ -103,7 +103,8 @@ def test_complex_mixed_table(tmp_path, setup_path): index=list("abcd"), ) - with ensure_clean_store(setup_path) as store: + path = tmp_path / setup_path + with HDFStore(path) as store: store.append("df", df, data_columns=["A", "B"]) result = store.select("df", where="A>2") tm.assert_frame_equal(df.loc[df.A > 2], result) @@ -139,7 +140,7 @@ def test_complex_across_dimensions(tmp_path, setup_path): tm.assert_frame_equal(df, reread) -def test_complex_indexing_error(setup_path): +def test_complex_indexing_error(tmp_path, setup_path): complex128 = np.array( [1.0 + 1.0j, 1.0 + 1.0j, 1.0 + 1.0j, 1.0 + 1.0j], dtype=np.complex128 ) @@ -156,7 +157,8 @@ def test_complex_indexing_error(setup_path): "values to data_columns when initializing the table." ) - with ensure_clean_store(setup_path) as store: + path = tmp_path / setup_path + with HDFStore(path) as store: with pytest.raises(TypeError, match=msg): store.append("df", df, data_columns=["C"]) @@ -183,7 +185,7 @@ def test_complex_series_error(tmp_path, setup_path): tm.assert_series_equal(s, reread) -def test_complex_append(setup_path): +def test_complex_append(tmp_path, setup_path): df = DataFrame( { "a": np.random.default_rng(2).standard_normal(100).astype(np.complex128), @@ -191,7 +193,8 @@ def test_complex_append(setup_path): } ) - with ensure_clean_store(setup_path) as store: + path = tmp_path / setup_path + with HDFStore(path) as store: store.append("df", df, data_columns=["b"]) store.append("df", df) result = store.select("df")