From 3d2365463a70427e4cb5de8741f30a55c7ad0d59 Mon Sep 17 00:00:00 2001 From: Harrison Cook Date: Tue, 8 Oct 2024 14:30:16 +0000 Subject: [PATCH] Fix: Use `FileNotFoundError` when no file found rather than FileExistsError --- src/earthkit/data/readers/__init__.py | 2 +- tests/readers/test_empty_file.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/earthkit/data/readers/__init__.py b/src/earthkit/data/readers/__init__.py index fe107831..e4129d49 100644 --- a/src/earthkit/data/readers/__init__.py +++ b/src/earthkit/data/readers/__init__.py @@ -182,7 +182,7 @@ def reader(source, path, **kwargs): r = _non_existing(source, path, **kwargs) if r is not None: return r - raise FileExistsError(f"No such file exists: '{path}'") + raise FileNotFoundError(f"No such file exists: '{path}'") if os.path.getsize(path) == 0: r = _empty(source, path, **kwargs) diff --git a/tests/readers/test_empty_file.py b/tests/readers/test_empty_file.py index 4895cd1f..c4488677 100644 --- a/tests/readers/test_empty_file.py +++ b/tests/readers/test_empty_file.py @@ -21,7 +21,7 @@ def test_empty_file_reader(): def test_nonexisting_file_reader(): - with pytest.raises(FileExistsError): + with pytest.raises(FileNotFoundError): earthkit.data.from_source("file", "__nonexistingfile__")