diff options
author | Joannah Nanjekye <33177550+nanjekyejoannah@users.noreply.github.com> | 2019-05-04 15:27:10 (GMT) |
---|---|---|
committer | Antoine Pitrou <antoine@python.org> | 2019-05-04 15:27:10 (GMT) |
commit | 6b5b013bcc22a27d6231c2796882e44ddb42be67 (patch) | |
tree | 3542414369283f216bb25a02f99ddea67180519e /Lib/test/test_pathlib.py | |
parent | f0900199d53df97bd792ac5a1678f8c477f117bb (diff) | |
download | cpython-6b5b013bcc22a27d6231c2796882e44ddb42be67.zip cpython-6b5b013bcc22a27d6231c2796882e44ddb42be67.tar.gz cpython-6b5b013bcc22a27d6231c2796882e44ddb42be67.tar.bz2 |
bpo-26978: Implement pathlib.Path.link_to (Using os.link) (GH-12990)
Diffstat (limited to 'Lib/test/test_pathlib.py')
-rw-r--r-- | Lib/test/test_pathlib.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py index f8325eb..990207b 100644 --- a/Lib/test/test_pathlib.py +++ b/Lib/test/test_pathlib.py @@ -1643,6 +1643,25 @@ class _BasePathTest(object): self.assertFileNotFound(p.stat) self.assertFileNotFound(p.unlink) + def test_link_to(self): + P = self.cls(BASE) + p = P / 'fileA' + size = p.stat().st_size + # linking to another path. + q = P / 'dirA' / 'fileAA' + try: + p.link_to(q) + except PermissionError as e: + self.skipTest('os.link(): %s' % e) + self.assertEqual(q.stat().st_size, size) + self.assertEqual(os.path.samefile(p, q), True) + self.assertTrue(p.stat) + # Linking to a str of a relative path. + r = rel_join('fileAAA') + q.link_to(r) + self.assertEqual(os.stat(r).st_size, size) + self.assertTrue(q.stat) + def test_rename(self): P = self.cls(BASE) p = P / 'fileA' |