diff options
author | Charles-François Natali <neologix@free.fr> | 2012-01-08 17:34:06 (GMT) |
---|---|---|
committer | Charles-François Natali <neologix@free.fr> | 2012-01-08 17:34:06 (GMT) |
commit | 7546ad327d8aff40314154650d9540cd396a2678 (patch) | |
tree | 3d9f4aab8a88410d4efdd062d569735c230bfc42 /Lib/test/test_posix.py | |
parent | 94f6fa62bf111916a44e336c25deeac2c490ec98 (diff) | |
download | cpython-7546ad327d8aff40314154650d9540cd396a2678.zip cpython-7546ad327d8aff40314154650d9540cd396a2678.tar.gz cpython-7546ad327d8aff40314154650d9540cd396a2678.tar.bz2 |
Issue #13739: In os.listdir(), rewind the directory stream (so that listdir()
can be called again on the same open file).
Diffstat (limited to 'Lib/test/test_posix.py')
-rw-r--r-- | Lib/test/test_posix.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py index 3c863a7..07755b9 100644 --- a/Lib/test/test_posix.py +++ b/Lib/test/test_posix.py @@ -454,14 +454,22 @@ class PosixTester(unittest.TestCase): @unittest.skipUnless(hasattr(posix, 'fdlistdir'), "test needs posix.fdlistdir()") def test_fdlistdir(self): f = posix.open(posix.getcwd(), posix.O_RDONLY) + self.addCleanup(posix.close, f) + f1 = posix.dup(f) self.assertEqual( sorted(posix.listdir('.')), - sorted(posix.fdlistdir(f)) + sorted(posix.fdlistdir(f1)) ) # Check the fd was closed by fdlistdir with self.assertRaises(OSError) as ctx: - posix.close(f) + posix.close(f1) self.assertEqual(ctx.exception.errno, errno.EBADF) + # Check that the fd offset was reset (issue #13739) + f2 = posix.dup(f) + self.assertEqual( + sorted(posix.listdir('.')), + sorted(posix.fdlistdir(f2)) + ) def test_access(self): if hasattr(posix, 'access'): |