Skip to content

Commit 734e235

Browse files
committed
Preserve case when sorting sorting paths in sort_paths
1 parent ee7d051 commit 734e235

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

domdf_python_tools/paths.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
import sys
5252
import tempfile
5353
from collections import defaultdict, deque
54+
from operator import methodcaller
5455
from typing import IO, Any, Callable, ContextManager, Dict, Iterable, Iterator, List, Optional, TypeVar, Union
5556

5657
# this package
@@ -1035,4 +1036,4 @@ def sort_paths(*paths: PathLike) -> List[PathPlus]:
10351036
contents = [path.relative_to(directory) for path in contents]
10361037
files.extend(PathPlus(directory) / path for path in sort_paths(*contents))
10371038

1038-
return files + sorted(local_contents)
1039+
return files + sorted(local_contents, key=methodcaller("as_posix"))

tests/test_paths.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -869,12 +869,13 @@ def test_temporarypathplus():
869869

870870

871871
def test_sort_paths():
872-
paths = ["foo.txt", "bar.toml", "bar.py", "baz.yaml", "fizz/buzz.c", "fizz/buzz.h"]
872+
paths = ["foo.txt", "bar.toml", "bar.py", "baz.yaml", "baz.YAML", "fizz/buzz.c", "fizz/buzz.h"]
873873
expected = [
874874
PathPlus("fizz/buzz.c"),
875875
PathPlus("fizz/buzz.h"),
876876
PathPlus("bar.py"),
877877
PathPlus("bar.toml"),
878+
PathPlus("baz.YAML"),
878879
PathPlus("baz.yaml"),
879880
PathPlus("foo.txt"),
880881
]

0 commit comments

Comments
 (0)