mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
gh-78707: deprecate passing >1 argument to PurePath.[is_]relative_to()
(GH-94469)
This brings `relative_to()` and `is_relative_to()` more in line with other pathlib methods like `rename()` and `symlink_to()`. Resolves #78707.
This commit is contained in:
parent
432117cd1f
commit
5a991da329
4 changed files with 35 additions and 14 deletions
|
@ -654,8 +654,9 @@ class _BasePurePathTest(object):
|
|||
self.assertEqual(p.relative_to(P('c'), walk_up=True), P('../a/b'))
|
||||
self.assertEqual(p.relative_to('c', walk_up=True), P('../a/b'))
|
||||
# With several args.
|
||||
self.assertEqual(p.relative_to('a', 'b'), P())
|
||||
self.assertEqual(p.relative_to('a', 'b', walk_up=True), P())
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
p.relative_to('a', 'b')
|
||||
p.relative_to('a', 'b', walk_up=True)
|
||||
# Unrelated paths.
|
||||
self.assertRaises(ValueError, p.relative_to, P('c'))
|
||||
self.assertRaises(ValueError, p.relative_to, P('a/b/c'))
|
||||
|
@ -706,7 +707,8 @@ class _BasePurePathTest(object):
|
|||
self.assertTrue(p.is_relative_to(P('a/b')))
|
||||
self.assertTrue(p.is_relative_to('a/b'))
|
||||
# With several args.
|
||||
self.assertTrue(p.is_relative_to('a', 'b'))
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
p.is_relative_to('a', 'b')
|
||||
# Unrelated paths.
|
||||
self.assertFalse(p.is_relative_to(P('c')))
|
||||
self.assertFalse(p.is_relative_to(P('a/b/c')))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue