#4764 set IOError.filename when trying to open a directory on POSIX platforms

This commit is contained in:
Benjamin Peterson 2008-12-29 17:47:42 +00:00
parent 732479f50b
commit fe231b07e4
3 changed files with 18 additions and 2 deletions

View file

@ -125,6 +125,19 @@ class AutoFileTests(unittest.TestCase):
class OtherFileTests(unittest.TestCase):
def testOpenDir(self):
this_dir = os.path.dirname(__file__)
for mode in (None, "w"):
try:
if mode:
f = open(this_dir, mode)
else:
f = open(this_dir)
except IOError as e:
self.assertEqual(e.filename, this_dir)
else:
self.fail("opening a directory didn't raise an IOError")
def testModeStrings(self):
# check invalid mode strings
for mode in ("", "aU", "wU+"):