From 8250e23abd12da20fcb03e2314fe6c34b403b534 Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Fri, 25 Feb 2011 23:41:16 +0000 Subject: Issue #10755: Add the posix.fdlistdir() function. Patch by Ross Lagerwall. --- Lib/test/test_posix.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'Lib/test/test_posix.py') 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)) -- cgit v1.2.1