Skip to content

Commit aa83473

Browse files
committed
TST: use ensure_clean_path context manager
1 parent d2a9882 commit aa83473

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
@@ -5199,18 +5199,18 @@ def pytables_hdf5_file():
51995199
{'c0': t0 + 3, 'c1': 'ddddd', 'c2': 4294967295},
52005200
]
52015201

5202-
# This returns a path and does not open the file.
5203-
tmpfilepath = create_tempfile('pytables_hdf5_file')
5204-
objectname = 'pandas_test_timeseries'
5205-
5206-
with tables.open_file(tmpfilepath, mode='w') as hf:
5207-
t = hf.create_table('/', name=objectname, description=table_schema)
5208-
for sample in testsamples:
5209-
for key, value in sample.items():
5210-
t.row[key] = value
5211-
t.row.append()
5212-
5213-
return tmpfilepath, objectname, pd.DataFrame(testsamples)
5202+
objname = 'pandas_test_timeseries'
5203+
5204+
with ensure_clean_path('pytables_hdf5_file') as path:
5205+
# The `ensure_clean_path` context mgr removes the temp file upon exit.
5206+
with tables.open_file(path, mode='w') as f:
5207+
t = f.create_table('/', name=objname, description=table_schema)
5208+
for sample in testsamples:
5209+
for key, value in sample.items():
5210+
t.row[key] = value
5211+
t.row.append()
5212+
5213+
yield path, objname, pd.DataFrame(testsamples)
52145214

52155215

52165216
class TestReadPyTablesHDF5:

0 commit comments

Comments
 (0)