diff options
| author | Antoine Pitrou <solipsis@pitrou.net> | 2012-07-06 16:48:24 (GMT) | 
|---|---|---|
| committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-07-06 16:48:24 (GMT) | 
| commit | 9235b254dcad979abe36be1024f8e89b04c764be (patch) | |
| tree | 21333ef9c9b354715db5d029da445f5209bb9227 /Lib/test/test_fileio.py | |
| parent | 01cca5e45185474bdb3c621c5dec4bfc0b323483 (diff) | |
| download | cpython-9235b254dcad979abe36be1024f8e89b04c764be.zip cpython-9235b254dcad979abe36be1024f8e89b04c764be.tar.gz cpython-9235b254dcad979abe36be1024f8e89b04c764be.tar.bz2  | |
Issue #15247: FileIO now raises an error when given a file descriptor pointing to a directory.
Diffstat (limited to 'Lib/test/test_fileio.py')
| -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 173ec25..5504ea3 100644 --- a/Lib/test/test_fileio.py +++ b/Lib/test/test_fileio.py @@ -127,6 +127,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):  | 
