Skip to content

Commit 6592d7f

Browse files
bpo-33752: Fix a file leak in test_dbm. (GH-7376)
With addCleanup() f.close() was executed after tearDown().
1 parent 415bc46 commit 6592d7f

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

Lib/test/test_dbm.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,8 @@ def test_anydbm_creation(self):
7575
def test_anydbm_creation_n_file_exists_with_invalid_contents(self):
7676
# create an empty file
7777
test.support.create_empty_file(_fname)
78-
79-
f = dbm.open(_fname, 'n')
80-
self.addCleanup(f.close)
81-
self.assertEqual(len(f), 0)
78+
with dbm.open(_fname, 'n') as f:
79+
self.assertEqual(len(f), 0)
8280

8381
def test_anydbm_modification(self):
8482
self.init_db()

0 commit comments

Comments
 (0)