diff options
author | Benjamin Peterson <benjamin@python.org> | 2008-12-29 17:47:42 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2008-12-29 17:47:42 (GMT) |
commit | fe231b07e41e8cfba8fb79e8440580c37e85183e (patch) | |
tree | f853a3113cab0f98737ca323007d75cce9bda8d6 /Lib/test/test_file.py | |
parent | 732479f50b46d4df153e178f844ad876e7f63bd8 (diff) | |
download | cpython-fe231b07e41e8cfba8fb79e8440580c37e85183e.zip cpython-fe231b07e41e8cfba8fb79e8440580c37e85183e.tar.gz cpython-fe231b07e41e8cfba8fb79e8440580c37e85183e.tar.bz2 |
#4764 set IOError.filename when trying to open a directory on POSIX platforms
Diffstat (limited to 'Lib/test/test_file.py')
-rw-r--r-- | Lib/test/test_file.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_file.py b/Lib/test/test_file.py index 96f6da2..b4f494b 100644 --- a/Lib/test/test_file.py +++ b/Lib/test/test_file.py @@ -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+"): |