Skip to content

Commit 0bf7f2b

Browse files
TST: Replace ensure_clean_store with temp_file in test_time_series.py
Replace ensure_clean_store utility function with the temp_file pytest fixture in pandas/tests/io/pytables/test_time_series.py. Changes: - Remove import of ensure_clean_store from pandas.tests.io.pytables.common - Add HDFStore to pandas imports - Replace setup_path parameter with temp_file in all test functions - Replace context manager usage of ensure_clean_store(setup_path) with HDFStore(temp_file) Contributes to issue #62435
1 parent 1863adb commit 0bf7f2b

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

pandas/tests/io/pytables/test_time_series.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,33 @@
11
import datetime
2-
32
import numpy as np
43
import pytest
54

65
from pandas import (
76
DataFrame,
87
DatetimeIndex,
8+
HDFStore,
99
Series,
1010
_testing as tm,
1111
date_range,
1212
period_range,
1313
)
14-
from pandas.tests.io.pytables.common import ensure_clean_store
1514

1615
pytestmark = pytest.mark.single_cpu
1716

1817

1918
@pytest.mark.parametrize("unit", ["us", "ns"])
20-
def test_store_datetime_fractional_secs(setup_path, unit):
19+
def test_store_datetime_fractional_secs(temp_file, unit):
2120
dt = datetime.datetime(2012, 1, 2, 3, 4, 5, 123456)
2221
dti = DatetimeIndex([dt], dtype=f"M8[{unit}]")
2322
series = Series([0], index=dti)
24-
with ensure_clean_store(setup_path) as store:
23+
with HDFStore(temp_file) as store:
2524
store["a"] = series
2625
assert store["a"].index[0] == dt
2726

2827

2928
@pytest.mark.filterwarnings(r"ignore:PeriodDtype\[B\] is deprecated:FutureWarning")
30-
def test_tseries_indices_series(setup_path):
31-
with ensure_clean_store(setup_path) as store:
29+
def test_tseries_indices_series(temp_file):
30+
with HDFStore(temp_file) as store:
3231
idx = date_range("2020-01-01", periods=10)
3332
ser = Series(np.random.default_rng(2).standard_normal(len(idx)), idx)
3433
store["a"] = ser
@@ -49,8 +48,8 @@ def test_tseries_indices_series(setup_path):
4948

5049

5150
@pytest.mark.filterwarnings(r"ignore:PeriodDtype\[B\] is deprecated:FutureWarning")
52-
def test_tseries_indices_frame(setup_path):
53-
with ensure_clean_store(setup_path) as store:
51+
def test_tseries_indices_frame(temp_file):
52+
with HDFStore(temp_file) as store:
5453
idx = date_range("2020-01-01", periods=10)
5554
df = DataFrame(
5655
np.random.default_rng(2).standard_normal((len(idx), 3)), index=idx

0 commit comments

Comments
 (0)