mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #10755: Add the posix.fdlistdir() function. Patch by Ross Lagerwall.
This commit is contained in:
parent
f65132de3d
commit
8250e23abd
7 changed files with 108 additions and 5 deletions
|
@ -285,6 +285,18 @@ class PosixTester(unittest.TestCase):
|
|||
if hasattr(posix, 'listdir'):
|
||||
self.assertTrue(support.TESTFN in posix.listdir())
|
||||
|
||||
@unittest.skipUnless(hasattr(posix, 'fdlistdir'), "test needs posix.fdlistdir()")
|
||||
def test_fdlistdir(self):
|
||||
f = posix.open(posix.getcwd(), posix.O_RDONLY)
|
||||
self.assertEqual(
|
||||
sorted(posix.listdir('.')),
|
||||
sorted(posix.fdlistdir(f))
|
||||
)
|
||||
# Check the fd was closed by fdlistdir
|
||||
with self.assertRaises(OSError) as ctx:
|
||||
posix.close(f)
|
||||
self.assertEqual(ctx.exception.errno, errno.EBADF)
|
||||
|
||||
def test_access(self):
|
||||
if hasattr(posix, 'access'):
|
||||
self.assertTrue(posix.access(support.TESTFN, os.R_OK))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue