summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorBarney Gale <barney.gale@gmail.com>2023-05-02 23:16:04 (GMT)
committerGitHub <noreply@github.com>2023-05-02 23:16:04 (GMT)
commit65a49c6553a27cc36eebb4b79f409c3cb4450d8c (patch)
tree63dd98d6a2c362deee109cfc92e8f83c98dca7d8 /Lib/test
parent47770a1e91d096fd1c689eb0c78b0f9e76b43639 (diff)
downloadcpython-65a49c6553a27cc36eebb4b79f409c3cb4450d8c.zip
cpython-65a49c6553a27cc36eebb4b79f409c3cb4450d8c.tar.gz
cpython-65a49c6553a27cc36eebb4b79f409c3cb4450d8c.tar.bz2
GH-104102: Optimize `pathlib.Path.glob()` handling of `../` pattern segments (GH-104103)
These segments do not require a `stat()` call, as the selector's `_select_from()` method is called after we've established that the parent is a directory.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_pathlib.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py
index 8b5b61a..9902b72 100644
--- a/Lib/test/test_pathlib.py
+++ b/Lib/test/test_pathlib.py
@@ -1892,8 +1892,13 @@ class _BasePathTest(object):
P = self.cls
p = P(BASE)
self.assertEqual(set(p.glob("..")), { P(BASE, "..") })
+ self.assertEqual(set(p.glob("../..")), { P(BASE, "..", "..") })
+ self.assertEqual(set(p.glob("dirA/..")), { P(BASE, "dirA", "..") })
self.assertEqual(set(p.glob("dirA/../file*")), { P(BASE, "dirA/../fileA") })
+ self.assertEqual(set(p.glob("dirA/../file*/..")), set())
self.assertEqual(set(p.glob("../xyzzy")), set())
+ self.assertEqual(set(p.glob("xyzzy/..")), set())
+ self.assertEqual(set(p.glob("/".join([".."] * 50))), { P(BASE, *[".."] * 50)})
@os_helper.skip_unless_symlink
def test_glob_permissions(self):