| 222 | |
| 223 | |
| 224 | def test_read_hdf_errors(temp_h5_path): |
| 225 | df = DataFrame( |
| 226 | np.random.default_rng(2).random((4, 5)), |
| 227 | index=list("abcd"), |
| 228 | columns=list("ABCDE"), |
| 229 | ) |
| 230 | |
| 231 | msg = r"File [\S]* does not exist" |
| 232 | with pytest.raises(OSError, match=msg): |
| 233 | read_hdf(f"{uuid.uuid4()}.h5", "key") |
| 234 | |
| 235 | df.to_hdf(temp_h5_path, key="df") |
| 236 | store = HDFStore(temp_h5_path, mode="r") |
| 237 | store.close() |
| 238 | |
| 239 | msg = "The HDFStore must be open for reading." |
| 240 | with pytest.raises(OSError, match=msg): |
| 241 | read_hdf(store, "df") |
| 242 | |
| 243 | |
| 244 | def test_read_hdf_generic_buffer_errors(): |