Raise error on invalid path. Fixes #5

This commit is contained in:
ljnsn 2022-12-20 01:27:12 +01:00
parent 538120ce82
commit aa4e0cd60c
2 changed files with 9 additions and 0 deletions

View File

@ -34,6 +34,9 @@ def read_ods(
Returns:
The content of the specified sheet as a DataFrame.
"""
path = file_or_path if isinstance(file_or_path, Path) else Path(file_or_path)
if not path.is_file():
raise FileNotFoundError(f"file {file_or_path} does not exist")
backend = EXT_MAP.get(Path(file_or_path).suffix, ods)
return algo.read_data(
backend,

View File

@ -156,3 +156,9 @@ class TestOdsReader:
assert len(df) == 8
assert len(df.columns) == 5
assert df.columns.tolist() == ["a", "b", "c", "d", "e"]
def test_invalid_path(self):
path = rsc / "does-not-exist.ods"
with pytest.raises(FileNotFoundError, match="does not exist"):
read_ods(path)