mirror of
https://github.com/python/cpython.git
synced 2026-01-26 17:22:25 +00:00
bpo-33752: Fix a file leak in test_dbm. (GH-7376)
With addCleanup() f.close() was executed after tearDown().
(cherry picked from commit 6592d7fe11)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
ae55d29fe0
commit
194a5c0722
1 changed files with 2 additions and 4 deletions
|
|
@ -75,10 +75,8 @@ def test_anydbm_creation(self):
|
|||
def test_anydbm_creation_n_file_exists_with_invalid_contents(self):
|
||||
# create an empty file
|
||||
test.support.create_empty_file(_fname)
|
||||
|
||||
f = dbm.open(_fname, 'n')
|
||||
self.addCleanup(f.close)
|
||||
self.assertEqual(len(f), 0)
|
||||
with dbm.open(_fname, 'n') as f:
|
||||
self.assertEqual(len(f), 0)
|
||||
|
||||
def test_anydbm_modification(self):
|
||||
self.init_db()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue