File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -1301,6 +1301,21 @@ def test_read_missing_key_close_store(self):
1301
1301
# read with KeyError before another write
1302
1302
df .to_hdf (path , "k2" )
1303
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
+
1304
1319
def test_append_frame_column_oriented (self ):
1305
1320
1306
1321
with ensure_clean_store (self .path ) as store :
You can’t perform that action at this time.
0 commit comments