diff options
author | Barney Gale <barney.gale@gmail.com> | 2022-12-17 00:14:27 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-17 00:14:27 (GMT) |
commit | 5a991da32961ef5780996d58b8816d5f2085f540 (patch) | |
tree | 604f148e9a3578ae854c8cd6eeb293d44a5042a1 /Lib/test | |
parent | 432117cd1f59c76d97da2eaff55a7d758301dbc7 (diff) | |
download | cpython-5a991da32961ef5780996d58b8816d5f2085f540.zip cpython-5a991da32961ef5780996d58b8816d5f2085f540.tar.gz cpython-5a991da32961ef5780996d58b8816d5f2085f540.tar.bz2 |
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.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_pathlib.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py index 1d01d3c..fa6ea0a 100644 --- a/Lib/test/test_pathlib.py +++ b/Lib/test/test_pathlib.py @@ -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'))) |