Kaydet (Commit) c0eee315 authored tarafından Brett Cannon's avatar Brett Cannon

Properly close files in test_dbm_dumb.

üst 5ede1493
...@@ -132,12 +132,14 @@ class DumbDBMTestCase(unittest.TestCase): ...@@ -132,12 +132,14 @@ class DumbDBMTestCase(unittest.TestCase):
f.close() f.close()
# Mangle the file by changing the line separator to Windows or Unix # 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': if os.linesep == '\n':
data = data.replace(b'\n', b'\r\n') data = data.replace(b'\n', b'\r\n')
else: else:
data = data.replace(b'\r\n', b'\n') 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) f = dumbdbm.open(_fname)
self.assertEqual(f[b'1'], b'hello') self.assertEqual(f[b'1'], b'hello')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment