Skip to content

Commit b913f47

Browse files
bpo-39950: Fix deprecation warning in test for pathlib.Path.link_to() (GH-26155) (GH-26178)
(cherry picked from commit 1a08c5a) Co-authored-by: Barney Gale <[email protected]>
1 parent 68b79f7 commit b913f47

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

Lib/pathlib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1265,7 +1265,7 @@ def link_to(self, target):
12651265
warnings.warn("pathlib.Path.link_to() is deprecated and is scheduled "
12661266
"for removal in Python 3.12. "
12671267
"Use pathlib.Path.hardlink_to() instead.",
1268-
DeprecationWarning)
1268+
DeprecationWarning, stacklevel=2)
12691269
self._accessor.link(self, target)
12701270

12711271
# Convenience functions for querying the stat results

Lib/test/test_pathlib.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1934,7 +1934,8 @@ def test_link_to(self):
19341934
self.assertTrue(p.stat)
19351935
# Linking to a str of a relative path.
19361936
r = rel_join('fileAAA')
1937-
q.link_to(r)
1937+
with self.assertWarns(DeprecationWarning):
1938+
q.link_to(r)
19381939
self.assertEqual(os.stat(r).st_size, size)
19391940
self.assertTrue(q.stat)
19401941

0 commit comments

Comments
 (0)