Skip to content

Commit 754ad30

Browse files
committed
FIX-#2527: Use random name for hdf file test, clean file after testing
Signed-off-by: Vasilij Litvinov <[email protected]>
1 parent 2592849 commit 754ad30

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

modin/pandas/test/test_io.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import shutil
2727
import sqlalchemy as sa
2828
import csv
29+
import tempfile
2930

3031
from .utils import (
3132
check_file_leaks,
@@ -2014,14 +2015,18 @@ def test_HDFStore():
20142015

20152016
assert isinstance(modin_store, pd.HDFStore)
20162017

2017-
hdf_file = "/tmp/test_read_hdf.hdf5"
2018-
with pd.HDFStore(hdf_file, mode="w") as store:
2019-
store.append("data/df1", pd.DataFrame(np.random.randn(5, 5)))
2020-
store.append("data/df2", pd.DataFrame(np.random.randn(4, 4)))
2018+
handle, hdf_file = tempfile.mkstemp(suffix=".hdf5", prefix="test_read")
2019+
os.close(handle)
2020+
try:
2021+
with pd.HDFStore(hdf_file, mode="w") as store:
2022+
store.append("data/df1", pd.DataFrame(np.random.randn(5, 5)))
2023+
store.append("data/df2", pd.DataFrame(np.random.randn(4, 4)))
20212024

2022-
modin_df = pd.read_hdf(hdf_file, key="data/df1", mode="r")
2023-
pandas_df = pandas.read_hdf(hdf_file, key="data/df1", mode="r")
2024-
df_equals(modin_df, pandas_df)
2025+
modin_df = pd.read_hdf(hdf_file, key="data/df1", mode="r")
2026+
pandas_df = pandas.read_hdf(hdf_file, key="data/df1", mode="r")
2027+
df_equals(modin_df, pandas_df)
2028+
finally:
2029+
os.unlink(hdf_file)
20252030

20262031

20272032
def test_ExcelFile():

0 commit comments

Comments
 (0)