summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_pathlib.py
diff options
context:
space:
mode:
authorBarney Gale <barney.gale@gmail.com>2023-05-04 16:44:36 (GMT)
committerGitHub <noreply@github.com>2023-05-04 16:44:36 (GMT)
commit8100be5535073a5442c2b8c68dcb2093ee69433d (patch)
tree01749fcfb9759f8a7471068fa58ab462d70382fc /Lib/test/test_pathlib.py
parent09b7695f12f2b44d2df6898407d7e68dd9493ed4 (diff)
downloadcpython-8100be5535073a5442c2b8c68dcb2093ee69433d.zip
cpython-8100be5535073a5442c2b8c68dcb2093ee69433d.tar.gz
cpython-8100be5535073a5442c2b8c68dcb2093ee69433d.tar.bz2
GH-81079: Add case_sensitive argument to `pathlib.Path.glob()` (GH-102710)
This argument allows case-sensitive matching to be enabled on Windows, and case-insensitive matching to be enabled on Posix. Co-authored-by: Steve Dower <steve.dower@microsoft.com>
Diffstat (limited to 'Lib/test/test_pathlib.py')
-rw-r--r--Lib/test/test_pathlib.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py
index 424bb92..a932e03 100644
--- a/Lib/test/test_pathlib.py
+++ b/Lib/test/test_pathlib.py
@@ -1816,6 +1816,18 @@ class _BasePathTest(object):
else:
_check(p.glob("*/"), ["dirA", "dirB", "dirC", "dirE", "linkB"])
+ def test_glob_case_sensitive(self):
+ P = self.cls
+ def _check(path, pattern, case_sensitive, expected):
+ actual = {str(q) for q in path.glob(pattern, case_sensitive=case_sensitive)}
+ expected = {str(P(BASE, q)) for q in expected}
+ self.assertEqual(actual, expected)
+ path = P(BASE)
+ _check(path, "DIRB/FILE*", True, [])
+ _check(path, "DIRB/FILE*", False, ["dirB/fileB"])
+ _check(path, "dirb/file*", True, [])
+ _check(path, "dirb/file*", False, ["dirB/fileB"])
+
def test_rglob_common(self):
def _check(glob, expected):
self.assertEqual(set(glob), { P(BASE, q) for q in expected })