mirror of https://github.com/python/cpython.git
bpo-39950: Fix deprecation warning in test for `pathlib.Path.link_to()` (GH-26155) (GH-26178)
(cherry picked from commit 1a08c5ac49
)
Co-authored-by: Barney Gale <barney.gale@gmail.com>
This commit is contained in:
parent
68b79f75c5
commit
b913f47e87
|
@ -1265,7 +1265,7 @@ def link_to(self, target):
|
||||||
warnings.warn("pathlib.Path.link_to() is deprecated and is scheduled "
|
warnings.warn("pathlib.Path.link_to() is deprecated and is scheduled "
|
||||||
"for removal in Python 3.12. "
|
"for removal in Python 3.12. "
|
||||||
"Use pathlib.Path.hardlink_to() instead.",
|
"Use pathlib.Path.hardlink_to() instead.",
|
||||||
DeprecationWarning)
|
DeprecationWarning, stacklevel=2)
|
||||||
self._accessor.link(self, target)
|
self._accessor.link(self, target)
|
||||||
|
|
||||||
# Convenience functions for querying the stat results
|
# Convenience functions for querying the stat results
|
||||||
|
|
|
@ -1934,6 +1934,7 @@ def test_link_to(self):
|
||||||
self.assertTrue(p.stat)
|
self.assertTrue(p.stat)
|
||||||
# Linking to a str of a relative path.
|
# Linking to a str of a relative path.
|
||||||
r = rel_join('fileAAA')
|
r = rel_join('fileAAA')
|
||||||
|
with self.assertWarns(DeprecationWarning):
|
||||||
q.link_to(r)
|
q.link_to(r)
|
||||||
self.assertEqual(os.stat(r).st_size, size)
|
self.assertEqual(os.stat(r).st_size, size)
|
||||||
self.assertTrue(q.stat)
|
self.assertTrue(q.stat)
|
||||||
|
|
Loading…
Reference in New Issue