Skip to content

Commit db50e10

Browse files
roberthdevriesSeeminSyed
authored andcommitted
Fix HDFStore leak in tests/io/pytables/test_store.py (pandas-dev#32722)
1 parent 9be2416 commit db50e10

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

pandas/tests/io/pytables/test_store.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -1217,14 +1217,14 @@ def test_read_missing_key_opened_store(self, setup_path):
12171217
df = pd.DataFrame({"a": range(2), "b": range(2)})
12181218
df.to_hdf(path, "k1")
12191219

1220-
store = pd.HDFStore(path, "r")
1220+
with pd.HDFStore(path, "r") as store:
12211221

1222-
with pytest.raises(KeyError, match="'No object named k2 in the file'"):
1223-
pd.read_hdf(store, "k2")
1222+
with pytest.raises(KeyError, match="'No object named k2 in the file'"):
1223+
pd.read_hdf(store, "k2")
12241224

1225-
# Test that the file is still open after a KeyError and that we can
1226-
# still read from it.
1227-
pd.read_hdf(store, "k1")
1225+
# Test that the file is still open after a KeyError and that we can
1226+
# still read from it.
1227+
pd.read_hdf(store, "k1")
12281228

12291229
def test_append_frame_column_oriented(self, setup_path):
12301230
with ensure_clean_store(setup_path) as store:

0 commit comments

Comments
 (0)