diff options
| author | Barney Gale <barney.gale@gmail.com> | 2023-07-03 20:29:44 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-03 20:29:44 (GMT) |
| commit | b4efdf8cda8fbbd0ca53b457d5f6e46a59348caf (patch) | |
| tree | a2dc7f0ed835a461a243fb3a1adc2855c40a8c9f /Lib/test/test_pathlib.py | |
| parent | e5862113dde7a66b08f1ece542a3cfaf0a3d9080 (diff) | |
| download | cpython-b4efdf8cda8fbbd0ca53b457d5f6e46a59348caf.zip cpython-b4efdf8cda8fbbd0ca53b457d5f6e46a59348caf.tar.gz cpython-b4efdf8cda8fbbd0ca53b457d5f6e46a59348caf.tar.bz2 | |
GH-106330: Fix matching of empty path in `pathlib.PurePath.match()` (GH-106331)
We match paths using the `_lines` attribute, which is derived from the
path's string representation. The bug arises because an empty path's string
representation is `'.'` (not `''`), which is matched by the `'*'` wildcard.
Diffstat (limited to 'Lib/test/test_pathlib.py')
| -rw-r--r-- | Lib/test/test_pathlib.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py index 464a835..eb2b0cf 100644 --- a/Lib/test/test_pathlib.py +++ b/Lib/test/test_pathlib.py @@ -384,6 +384,10 @@ class PurePathTest(unittest.TestCase): self.assertTrue(P('A.py').match('a.PY', case_sensitive=False)) self.assertFalse(P('c:/a/B.Py').match('C:/A/*.pY', case_sensitive=True)) self.assertTrue(P('/a/b/c.py').match('/A/*/*.Py', case_sensitive=False)) + # Matching against empty path + self.assertFalse(P().match('*')) + self.assertTrue(P().match('**')) + self.assertFalse(P().match('**/*')) def test_ordering_common(self): # Ordering is tuple-alike. |
