We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8fd2c39 commit 6481243Copy full SHA for 6481243
pandas/tests/io/pytables/test_pytables.py
@@ -1301,6 +1301,21 @@ def test_read_missing_key_close_store(self):
1301
# read with KeyError before another write
1302
df.to_hdf(path, "k2")
1303
1304
+ def test_read_missing_key_opened_store(self):
1305
+ # GH 28699
1306
+ with ensure_clean_path(self.path) as path:
1307
+ df = pd.DataFrame({"a": range(2), "b": range(2)})
1308
+ df.to_hdf(path, "k1")
1309
+
1310
+ store = pd.HDFStore(path, 'r')
1311
1312
+ with pytest.raises(KeyError, match="'No object named k2 in the file'"):
1313
+ pd.read_hdf(store, "k2")
1314
1315
+ # Test that the file is still open after a KeyError and that we can
1316
+ # still read from it.
1317
+ pd.read_hdf(store, "k1")
1318
1319
def test_append_frame_column_oriented(self):
1320
1321
with ensure_clean_store(self.path) as store:
0 commit comments