Skip to content

Commit db42246

Browse files
committed
changed exception to be ValueError when cache directory is a file, instead of a FileExistsError
1 parent ae9269d commit db42246

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

pydra/utils/hash.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,12 @@ def location_converter(path: ty.Union[Path, str, None]) -> Path:
6060
if path is None:
6161
path = PersistentCache.location_default()
6262
path = Path(path)
63-
path.mkdir(parents=True, exist_ok=True)
63+
try:
64+
path.mkdir(parents=True, exist_ok=True)
65+
except FileExistsError:
66+
raise ValueError(
67+
f"provided path to persistent cache {path} is a file not a directory"
68+
) from None
6469
return path
6570

6671

pydra/utils/tests/test_hash.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,5 +384,5 @@ def test_persistent_hash_cache_not_dir(text_file):
384384
"""
385385
Test that an error is raised if the provided cache path is not a directory
386386
"""
387-
with pytest.raises(FileExistsError):
387+
with pytest.raises(ValueError, match="not a directory"):
388388
PersistentCache(text_file.fspath)

0 commit comments

Comments
 (0)