Skip to content

Commit

Permalink
changed exception to be ValueError when cache directory is a file, in…
Browse files Browse the repository at this point in the history
…stead of a FileExistsError
  • Loading branch information
tclose committed Mar 17, 2024
1 parent ae9269d commit db42246
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion pydra/utils/hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@ def location_converter(path: ty.Union[Path, str, None]) -> Path:
if path is None:
path = PersistentCache.location_default()
path = Path(path)
path.mkdir(parents=True, exist_ok=True)
try:
path.mkdir(parents=True, exist_ok=True)
except FileExistsError:
raise ValueError(

Check warning on line 66 in pydra/utils/hash.py

View check run for this annotation

Codecov / codecov/patch

pydra/utils/hash.py#L65-L66

Added lines #L65 - L66 were not covered by tests
f"provided path to persistent cache {path} is a file not a directory"
) from None
return path


Expand Down
2 changes: 1 addition & 1 deletion pydra/utils/tests/test_hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,5 +384,5 @@ def test_persistent_hash_cache_not_dir(text_file):
"""
Test that an error is raised if the provided cache path is not a directory
"""
with pytest.raises(FileExistsError):
with pytest.raises(ValueError, match="not a directory"):
PersistentCache(text_file.fspath)

0 comments on commit db42246

Please sign in to comment.