summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/pathlib.py2
-rw-r--r--Lib/test/test_pathlib.py3
2 files changed, 3 insertions, 2 deletions
diff --git a/Lib/pathlib.py b/Lib/pathlib.py
index 94e079f..8e6eb48 100644
--- a/Lib/pathlib.py
+++ b/Lib/pathlib.py
@@ -1265,7 +1265,7 @@ class Path(PurePath):
warnings.warn("pathlib.Path.link_to() is deprecated and is scheduled "
"for removal in Python 3.12. "
"Use pathlib.Path.hardlink_to() instead.",
- DeprecationWarning)
+ DeprecationWarning, stacklevel=2)
self._accessor.link(self, target)
# Convenience functions for querying the stat results
diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py
index 6ed08f7..55d63d5 100644
--- a/Lib/test/test_pathlib.py
+++ b/Lib/test/test_pathlib.py
@@ -1934,7 +1934,8 @@ class _BasePathTest(object):
self.assertTrue(p.stat)
# Linking to a str of a relative path.
r = rel_join('fileAAA')
- q.link_to(r)
+ with self.assertWarns(DeprecationWarning):
+ q.link_to(r)
self.assertEqual(os.stat(r).st_size, size)
self.assertTrue(q.stat)