mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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>
This commit is contained in:
parent
09b7695f12
commit
8100be5535
4 changed files with 51 additions and 17 deletions
|
@ -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 })
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue