mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
#4764 set IOError.filename when trying to open a directory on POSIX platforms
This commit is contained in:
parent
732479f50b
commit
fe231b07e4
3 changed files with 18 additions and 2 deletions
|
@ -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+"):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue