diff options
| author | Barney Gale <barney.gale@gmail.com> | 2023-08-04 23:12:12 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-04 23:12:12 (GMT) |
| commit | ec0a0d2bd9faa247d5b3208a8138e4399b2da890 (patch) | |
| tree | fdb578d6b96b11a174382dd202df84d50289eae7 /Lib/test/test_pathlib.py | |
| parent | 2c25bd82f46df72c89ca5bca10eaa06137ab8290 (diff) | |
| download | cpython-ec0a0d2bd9faa247d5b3208a8138e4399b2da890.zip cpython-ec0a0d2bd9faa247d5b3208a8138e4399b2da890.tar.gz cpython-ec0a0d2bd9faa247d5b3208a8138e4399b2da890.tar.bz2 | |
GH-70303: Emit FutureWarning when pathlib glob pattern ends with `**` (GH-105413)
In a future Python release, patterns with this ending will match both files
and directories. Users may add a trailing slash to remove the warning.
Diffstat (limited to 'Lib/test/test_pathlib.py')
| -rw-r--r-- | Lib/test/test_pathlib.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py index 5789a93..74deec8 100644 --- a/Lib/test/test_pathlib.py +++ b/Lib/test/test_pathlib.py @@ -1903,11 +1903,11 @@ class PathTest(unittest.TestCase): "dirC/dirD", "dirC/dirD/fileD"]) _check(p.rglob("file*"), ["dirC/fileC", "dirC/dirD/fileD"]) _check(p.rglob("**/file*"), ["dirC/fileC", "dirC/dirD/fileD"]) - _check(p.rglob("dir*/**"), ["dirC/dirD"]) + _check(p.rglob("dir*/**/"), ["dirC/dirD"]) _check(p.rglob("*/*"), ["dirC/dirD/fileD"]) _check(p.rglob("*/"), ["dirC/dirD"]) _check(p.rglob(""), ["dirC", "dirC/dirD"]) - _check(p.rglob("**"), ["dirC", "dirC/dirD"]) + _check(p.rglob("**/"), ["dirC", "dirC/dirD"]) # gh-91616, a re module regression _check(p.rglob("*.txt"), ["dirC/novel.txt"]) _check(p.rglob("*.*"), ["dirC/novel.txt"]) @@ -2057,7 +2057,20 @@ class PathTest(unittest.TestCase): path.mkdir(parents=True) with set_recursion_limit(recursion_limit): - list(base.glob('**')) + list(base.glob('**/')) + + def test_glob_recursive_no_trailing_slash(self): + P = self.cls + p = P(BASE) + with self.assertWarns(FutureWarning): + p.glob('**') + with self.assertWarns(FutureWarning): + p.glob('*/**') + with self.assertWarns(FutureWarning): + p.rglob('**') + with self.assertWarns(FutureWarning): + p.rglob('*/**') + def test_readlink(self): if not self.can_symlink: |
