mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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>
This commit is contained in:
parent
ffae93248a
commit
79d2e62c00
7 changed files with 15 additions and 5 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue