aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_pathlib.py
diff options
context:
space:
mode:
authorYaroslav Pankovych <31005942+ypankovych@users.noreply.github.com>2020-11-23 22:06:22 +0200
committerGitHub <noreply@github.com>2020-11-23 15:06:22 -0500
commit79d2e62c008446fbbc6f264bb8a30e2d38b6ff58 (patch)
tree19897f3bf2d3abafff8fbcda7c51bcbb446265b6 /Lib/test/test_pathlib.py
parentffae93248a33cd6fe73d1ea85d6802765bbf56d2 (diff)
downloadcpython-79d2e62c008446fbbc6f264bb8a30e2d38b6ff58.tar.gz
cpython-79d2e62c008446fbbc6f264bb8a30e2d38b6ff58.zip
Added support for negative indexes to PurePath.parents (GH-21799)
This commit also fixes up some of the overlapping documentation changed in bpo-35498, which added support for indexing with slices. Fixes bpo-21041. https://bugs.python.org/issue21041 Co-authored-by: Paul Ganssle <p.ganssle@gmail.com> Co-authored-by: Rémi Lapeyre <remi.lapeyre@henki.fr>
Diffstat (limited to 'Lib/test/test_pathlib.py')
-rw-r--r--Lib/test/test_pathlib.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py
index f1451796b64..5e5e065b988 100644
--- a/Lib/test/test_pathlib.py
+++ b/Lib/test/test_pathlib.py
@@ -440,6 +440,9 @@ class _BasePurePathTest(object):
self.assertEqual(par[0], P('a/b'))
self.assertEqual(par[1], P('a'))
self.assertEqual(par[2], P('.'))
+ self.assertEqual(par[-1], P('.'))
+ self.assertEqual(par[-2], P('a'))
+ self.assertEqual(par[-3], P('a/b'))
self.assertEqual(par[0:1], (P('a/b'),))
self.assertEqual(par[:2], (P('a/b'), P('a')))
self.assertEqual(par[:-1], (P('a/b'), P('a')))
@@ -448,7 +451,7 @@ class _BasePurePathTest(object):
self.assertEqual(par[::-1], (P('.'), P('a'), P('a/b')))
self.assertEqual(list(par), [P('a/b'), P('a'), P('.')])
with self.assertRaises(IndexError):
- par[-1]
+ par[-4]
with self.assertRaises(IndexError):
par[3]
with self.assertRaises(TypeError):