diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-07-06 16:52:58 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-07-06 16:52:58 (GMT) |
commit | 7d7f40c6131fee07fdae3c43ce4d7ef80c6dc650 (patch) | |
tree | d165ced64d5d4667b3c0a66f6315bb93d1787664 /Lib/test | |
parent | 5cf896fea8005478bcc2bcd6e10e4572ae5fe2be (diff) | |
parent | 9235b254dcad979abe36be1024f8e89b04c764be (diff) | |
download | cpython-7d7f40c6131fee07fdae3c43ce4d7ef80c6dc650.zip cpython-7d7f40c6131fee07fdae3c43ce4d7ef80c6dc650.tar.gz cpython-7d7f40c6131fee07fdae3c43ce4d7ef80c6dc650.tar.bz2 |
Issue #15247: FileIO now raises an error when given a file descriptor pointing to a directory.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_fileio.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_fileio.py b/Lib/test/test_fileio.py index 99f2069..906952c 100644 --- a/Lib/test/test_fileio.py +++ b/Lib/test/test_fileio.py @@ -128,6 +128,14 @@ class AutoFileTests(unittest.TestCase): else: self.fail("Should have raised IOError") + @unittest.skipIf(os.name == 'nt', "test only works on a POSIX-like system") + def testOpenDirFD(self): + fd = os.open('.', os.O_RDONLY) + with self.assertRaises(IOError) as cm: + _FileIO(fd, 'r') + os.close(fd) + self.assertEqual(cm.exception.errno, errno.EISDIR) + #A set of functions testing that we get expected behaviour if someone has #manually closed the internal file descriptor. First, a decorator: def ClosedFD(func): |