Skip to content

Commit 0751472

Browse files
committed
TST: use ensure_clean_path context manager
1 parent aefb48c commit 0751472

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

pandas/tests/io/test_pytables.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5189,18 +5189,18 @@ def pytables_hdf5_file():
51895189
{'c0': t0 + 3, 'c1': 'ddddd', 'c2': 4294967295},
51905190
]
51915191

5192-
# This returns a path and does not open the file.
5193-
tmpfilepath = create_tempfile('pytables_hdf5_file')
5194-
objectname = 'pandas_test_timeseries'
5195-
5196-
with tables.open_file(tmpfilepath, mode='w') as hf:
5197-
t = hf.create_table('/', name=objectname, description=table_schema)
5198-
for sample in testsamples:
5199-
for key, value in sample.items():
5200-
t.row[key] = value
5201-
t.row.append()
5202-
5203-
return tmpfilepath, objectname, pd.DataFrame(testsamples)
5192+
objname = 'pandas_test_timeseries'
5193+
5194+
with ensure_clean_path('pytables_hdf5_file') as path:
5195+
# The `ensure_clean_path` context mgr removes the temp file upon exit.
5196+
with tables.open_file(path, mode='w') as f:
5197+
t = f.create_table('/', name=objname, description=table_schema)
5198+
for sample in testsamples:
5199+
for key, value in sample.items():
5200+
t.row[key] = value
5201+
t.row.append()
5202+
5203+
yield path, objname, pd.DataFrame(testsamples)
52045204

52055205

52065206
class TestReadPyTablesHDF5:

0 commit comments

Comments
 (0)