summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2008-09-01 14:13:43 (GMT)
committerBenjamin Peterson <benjamin@python.org>2008-09-01 14:13:43 (GMT)
commitf22c26ecf4c28e16d262cdb1305411286fb925c9 (patch)
tree2f02372674b38da2f4915e5a3e5a86b580bb3172 /Lib/test
parentf07e5a9e4b5418829e0b2e907ae5e9b7bb8f90c8 (diff)
downloadcpython-f22c26ecf4c28e16d262cdb1305411286fb925c9.zip
cpython-f22c26ecf4c28e16d262cdb1305411286fb925c9.tar.gz
cpython-f22c26ecf4c28e16d262cdb1305411286fb925c9.tar.bz2
#3703 unhelpful _fileio.FileIO error message when trying to open a directory
Reviewer: Gregory P. Smith
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_fileio.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_fileio.py b/Lib/test/test_fileio.py
index a8b15fa..5a0e1a6 100644
--- a/Lib/test/test_fileio.py
+++ b/Lib/test/test_fileio.py
@@ -101,6 +101,17 @@ class AutoFileTests(unittest.TestCase):
# should raise on closed file
self.assertRaises(ValueError, method)
+ def testOpendir(self):
+ # Issue 3703: opening a directory should fill the errno
+ # Windows always returns "[Errno 13]: Permission denied
+ # Unix calls dircheck() and returns "[Errno 21]: Is a directory"
+ try:
+ _fileio._FileIO('.', 'r')
+ except IOError as e:
+ self.assertNotEqual(e.errno, 0)
+ else:
+ self.fail("Should have raised IOError")
+
class OtherFileTests(unittest.TestCase):