mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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
This commit is contained in:
parent
01659ca62c
commit
a01ba333af
5 changed files with 41 additions and 0 deletions
|
@ -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'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue