summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2018-06-05 13:03:00 (GMT)
committerGitHub <noreply@github.com>2018-06-05 13:03:00 (GMT)
commit6592d7fe11477f8f974d2d4a85c3382a1ad05217 (patch)
tree605cee9bddf55e30ebf29cef507c060dab35bf95 /Lib
parent415bc46a78e785f357c8960ae70f18a6b6cccbb6 (diff)
downloadcpython-6592d7fe11477f8f974d2d4a85c3382a1ad05217.zip
cpython-6592d7fe11477f8f974d2d4a85c3382a1ad05217.tar.gz
cpython-6592d7fe11477f8f974d2d4a85c3382a1ad05217.tar.bz2
bpo-33752: Fix a file leak in test_dbm. (GH-7376)
With addCleanup() f.close() was executed after tearDown().
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_dbm.py6
1 files changed, 2 insertions, 4 deletions
diff --git a/Lib/test/test_dbm.py b/Lib/test/test_dbm.py
index 78c32c4..1884b5c 100644
--- a/Lib/test/test_dbm.py
+++ b/Lib/test/test_dbm.py
@@ -75,10 +75,8 @@ class AnyDBMTestCase:
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()