summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_pathlib.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2022-05-11 04:14:40 (GMT)
committerGitHub <noreply@github.com>2022-05-11 04:14:40 (GMT)
commit5197134c1c392f3040a60c05f7bbb42c4bb24c46 (patch)
tree5b48edb972062a3ede8073af24fe464b6f5527b9 /Lib/test/test_pathlib.py
parent6a17cdebe9d3571d0c02645880f53a05e9ff7fda (diff)
downloadcpython-5197134c1c392f3040a60c05f7bbb42c4bb24c46.zip
cpython-5197134c1c392f3040a60c05f7bbb42c4bb24c46.tar.gz
cpython-5197134c1c392f3040a60c05f7bbb42c4bb24c46.tar.bz2
Revert "gh-92550 - Fix regression in `pathlib.Path.rglob()` (GH-92583)" (GH-92599)
This reverts commit a51baec9ce0eae2b4db069a55daf8f03be3ab2f4.
Diffstat (limited to 'Lib/test/test_pathlib.py')
-rw-r--r--Lib/test/test_pathlib.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py
index b8b08bf..6737068 100644
--- a/Lib/test/test_pathlib.py
+++ b/Lib/test/test_pathlib.py
@@ -1662,6 +1662,11 @@ class _BasePathTest(object):
else:
_check(p.glob("*/fileB"), ['dirB/fileB', 'linkB/fileB'])
+ if not os_helper.can_symlink():
+ _check(p.glob("*/"), ["dirA", "dirB", "dirC", "dirE"])
+ else:
+ _check(p.glob("*/"), ["dirA", "dirB", "dirC", "dirE", "linkB"])
+
def test_rglob_common(self):
def _check(glob, expected):
self.assertEqual(set(glob), { P(BASE, q) for q in expected })
@@ -1679,6 +1684,16 @@ class _BasePathTest(object):
"linkB/fileB", "dirA/linkC/fileB"])
_check(p.rglob("file*"), ["fileA", "dirB/fileB",
"dirC/fileC", "dirC/dirD/fileD"])
+ if not os_helper.can_symlink():
+ _check(p.rglob("*/"), [
+ "dirA", "dirB", "dirC", "dirC/dirD", "dirE",
+ ])
+ else:
+ _check(p.rglob("*/"), [
+ "dirA", "dirA/linkC", "dirB", "dirB/linkD", "dirC",
+ "dirC/dirD", "dirE", "linkB",
+ ])
+
p = P(BASE, "dirC")
_check(p.rglob("file*"), ["dirC/fileC", "dirC/dirD/fileD"])
_check(p.rglob("*/*"), ["dirC/dirD/fileD"])
@@ -2704,6 +2719,7 @@ class WindowsPathTest(_BasePathTest, unittest.TestCase):
P = self.cls
p = P(BASE)
self.assertEqual(set(p.glob("FILEa")), { P(BASE, "fileA") })
+ self.assertEqual(set(p.glob("*a\\")), { P(BASE, "dirA") })
self.assertEqual(set(p.glob("F*a")), { P(BASE, "fileA") })
self.assertEqual(set(map(str, p.glob("FILEa"))), {f"{p}\\FILEa"})
self.assertEqual(set(map(str, p.glob("F*a"))), {f"{p}\\fileA"})
@@ -2712,6 +2728,7 @@ class WindowsPathTest(_BasePathTest, unittest.TestCase):
P = self.cls
p = P(BASE, "dirC")
self.assertEqual(set(p.rglob("FILEd")), { P(BASE, "dirC/dirD/fileD") })
+ self.assertEqual(set(p.rglob("*\\")), { P(BASE, "dirC/dirD") })
self.assertEqual(set(map(str, p.rglob("FILEd"))), {f"{p}\\dirD\\FILEd"})
def test_expanduser(self):