diff options
author | Barney Gale <barney.gale@gmail.com> | 2024-01-20 02:10:25 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-20 02:10:25 (GMT) |
commit | 6313cdde58f34648a430d2830357c9d2a5b67b87 (patch) | |
tree | ab329b153fb95322934d83eaf62b9a6749d0f09c /Lib/test/test_pathlib/test_pathlib_abc.py | |
parent | 681e9e85a2c1f72576ddfbd766506e2d6db34862 (diff) | |
download | cpython-6313cdde58f34648a430d2830357c9d2a5b67b87.zip cpython-6313cdde58f34648a430d2830357c9d2a5b67b87.tar.gz cpython-6313cdde58f34648a430d2830357c9d2a5b67b87.tar.bz2 |
GH-79634: Accept path-like objects as pathlib glob patterns. (#114017)
Allow `os.PathLike` objects to be passed as patterns to `pathlib.Path.glob()` and `rglob()`. (It's already possible to use them in `PurePath.match()`)
While we're in the area:
- Allow empty glob patterns in `PathBase` (but not `Path`)
- Speed up globbing in `PathBase` by generating paths with trailing slashes only as a final step, rather than for every intermediate directory.
- Simplify and speed up handling of rare patterns involving both `**` and `..` segments.
Diffstat (limited to 'Lib/test/test_pathlib/test_pathlib_abc.py')
-rw-r--r-- | Lib/test/test_pathlib/test_pathlib_abc.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Lib/test/test_pathlib/test_pathlib_abc.py b/Lib/test/test_pathlib/test_pathlib_abc.py index f877c98..199718a 100644 --- a/Lib/test/test_pathlib/test_pathlib_abc.py +++ b/Lib/test/test_pathlib/test_pathlib_abc.py @@ -1045,9 +1045,12 @@ class DummyPathTest(DummyPurePathTest): _check(p.glob("*/"), ["dirA/", "dirB/", "dirC/", "dirE/", "linkB/"]) def test_glob_empty_pattern(self): - p = self.cls('') - with self.assertRaisesRegex(ValueError, 'Unacceptable pattern'): - list(p.glob('')) + def _check(glob, expected): + self.assertEqual(set(glob), { P(self.base, q) for q in expected }) + P = self.cls + p = P(self.base) + _check(p.glob(""), [""]) + _check(p.glob("."), ["."]) def test_glob_case_sensitive(self): P = self.cls |