Skip to content

Commit

Permalink
[general] add support for pathlib.PurePath to clean_name (#1278)
Browse files Browse the repository at this point in the history
Co-authored-by: Tom Andersen <tom.andersen@gmail.com>
  • Loading branch information
jschneier and tomandersen committed Aug 26, 2023
1 parent d547bb6 commit 65eb882
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions storages/utils.py
Expand Up @@ -34,9 +34,9 @@ def clean_name(name):
Normalize the name.
Includes cleaning up Windows style paths, ensuring an ending trailing slash,
and coercing from pathlib.Path.
and coercing from pathlib.PurePath.
"""
if isinstance(name, pathlib.Path):
if isinstance(name, pathlib.PurePath):
name = str(name)

# Normalize Windows style paths
Expand Down
3 changes: 3 additions & 0 deletions tests/test_utils.py
Expand Up @@ -26,6 +26,9 @@ def test_clean_name_pathlib(self):
path = pathlib.Path("path/to/anywhere")
self.assertEqual(utils.clean_name(path), "path/to/anywhere")

path = pathlib.PurePath("path/to/anywhere")
self.assertEqual(utils.clean_name(path), "path/to/anywhere")

def test_clean_name_normalize(self):
"""
Test the normalization of clean_name
Expand Down

0 comments on commit 65eb882

Please sign in to comment.