summaryrefslogtreecommitdiff
path: root/Lib/test/test_posix.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2011-02-25 23:41:16 +0000
committerAntoine Pitrou <solipsis@pitrou.net>2011-02-25 23:41:16 +0000
commit8250e23abd12da20fcb03e2314fe6c34b403b534 (patch)
tree74edbbc78231eeaebbc548a15e25cf95ba0e7061 /Lib/test/test_posix.py
parentf65132de3d00171b74bc81791cacc5abdbafe3e4 (diff)
downloadcpython-git-8250e23abd12da20fcb03e2314fe6c34b403b534.tar.gz
Issue #10755: Add the posix.fdlistdir() function. Patch by Ross Lagerwall.
Diffstat (limited to 'Lib/test/test_posix.py')
-rw-r--r--Lib/test/test_posix.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py
index 2fb8200e62..23c2100d7a 100644
--- a/Lib/test/test_posix.py
+++ b/Lib/test/test_posix.py
@@ -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))