diff options
author | Girts <girtsf@users.noreply.github.com> | 2019-10-23 21:18:40 (GMT) |
---|---|---|
committer | Miss Skeleton (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-10-23 21:18:40 (GMT) |
commit | a01ba333affcc0677146dc8af57179bdb808d608 (patch) | |
tree | 5b3c67ab51bc2c5074b19828c24de7a3d2eac119 /Lib/test/test_pathlib.py | |
parent | 01659ca62c4508518478a74615ac91c0009427ad (diff) | |
download | cpython-a01ba333affcc0677146dc8af57179bdb808d608.zip cpython-a01ba333affcc0677146dc8af57179bdb808d608.tar.gz cpython-a01ba333affcc0677146dc8af57179bdb808d608.tar.bz2 |
bpo-30618: add readlink to pathlib.Path (GH-8285)
This adds a "readlink" method to pathlib.Path objects that calls through
to os.readlink.
https://bugs.python.org/issue30618
Automerge-Triggered-By: @gpshead
Diffstat (limited to 'Lib/test/test_pathlib.py')
-rw-r--r-- | Lib/test/test_pathlib.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py index 221c272..058a201 100644 --- a/Lib/test/test_pathlib.py +++ b/Lib/test/test_pathlib.py @@ -1812,6 +1812,16 @@ class _BasePathTest(object): self.assertEqual(os.stat(r).st_size, size) self.assertFileNotFound(q.stat) + @support.skip_unless_symlink + def test_readlink(self): + P = self.cls(BASE) + self.assertEqual((P / 'linkA').readlink(), self.cls('fileA')) + self.assertEqual((P / 'brokenLink').readlink(), + self.cls('non-existing')) + self.assertEqual((P / 'linkB').readlink(), self.cls('dirB')) + with self.assertRaises(OSError): + (P / 'fileA').readlink() + def test_touch_common(self): P = self.cls(BASE) p = P / 'newfileA' |