mirror of
https://github.com/python/cpython.git
synced 2025-08-30 05:35:08 +00:00
bpo-22831: Use "with" to avoid possible fd leaks in tests (part 2). (GH-10929)
This commit is contained in:
parent
9e4861f523
commit
5b10b98247
25 changed files with 253 additions and 312 deletions
|
@ -1200,9 +1200,8 @@ class MakedirTests(unittest.TestCase):
|
|||
def test_exist_ok_existing_regular_file(self):
|
||||
base = support.TESTFN
|
||||
path = os.path.join(support.TESTFN, 'dir1')
|
||||
f = open(path, 'w')
|
||||
f.write('abc')
|
||||
f.close()
|
||||
with open(path, 'w') as f:
|
||||
f.write('abc')
|
||||
self.assertRaises(OSError, os.makedirs, path)
|
||||
self.assertRaises(OSError, os.makedirs, path, exist_ok=False)
|
||||
self.assertRaises(OSError, os.makedirs, path, exist_ok=True)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue