summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2010-10-29 22:49:14 (GMT)
committerBrett Cannon <bcannon@gmail.com>2010-10-29 22:49:14 (GMT)
commitc0eee315f5ea3efa6143f4b976ad2be80e3f182f (patch)
tree7580120c4cdb44aeedd80837aec86eccd9741a39
parent5ede149342983531629c5fcf20982008542fae02 (diff)
downloadcpython-c0eee315f5ea3efa6143f4b976ad2be80e3f182f.zip
cpython-c0eee315f5ea3efa6143f4b976ad2be80e3f182f.tar.gz
cpython-c0eee315f5ea3efa6143f4b976ad2be80e3f182f.tar.bz2
Properly close files in test_dbm_dumb.
-rw-r--r--Lib/test/test_dbm_dumb.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/test/test_dbm_dumb.py b/Lib/test/test_dbm_dumb.py
index a05db91..6b981c4 100644
--- a/Lib/test/test_dbm_dumb.py
+++ b/Lib/test/test_dbm_dumb.py
@@ -132,12 +132,14 @@ class DumbDBMTestCase(unittest.TestCase):
f.close()
# Mangle the file by changing the line separator to Windows or Unix
- data = io.open(_fname + '.dir', 'rb').read()
+ with io.open(_fname + '.dir', 'rb') as file:
+ data = file.read()
if os.linesep == '\n':
data = data.replace(b'\n', b'\r\n')
else:
data = data.replace(b'\r\n', b'\n')
- io.open(_fname + '.dir', 'wb').write(data)
+ with io.open(_fname + '.dir', 'wb') as file:
+ file.write(data)
f = dumbdbm.open(_fname)
self.assertEqual(f[b'1'], b'hello')