summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_dbm_dumb.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_dbm_dumb.py')
-rw-r--r--Lib/test/test_dbm_dumb.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/Lib/test/test_dbm_dumb.py b/Lib/test/test_dbm_dumb.py
index 956eec6..6b981c4 100644
--- a/Lib/test/test_dbm_dumb.py
+++ b/Lib/test/test_dbm_dumb.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""Test script for the dumbdbm module
Original by Roger E. Masse
"""
@@ -93,7 +93,7 @@ class DumbDBMTestCase(unittest.TestCase):
def test_write_contains(self):
f = dumbdbm.open(_fname)
f[b'1'] = b'hello'
- self.assertTrue(b'1' in f)
+ self.assertIn(b'1', f)
f.close()
def test_write_write_read(self):
@@ -118,7 +118,7 @@ class DumbDBMTestCase(unittest.TestCase):
f['1'] = 'a'
f.close()
f = dumbdbm.open(_fname, 'r')
- self.assertTrue('\u00fc' in f)
+ self.assertIn('\u00fc', f)
self.assertEqual(f['\u00fc'.encode('utf-8')],
self._dict['\u00fc'.encode('utf-8')])
self.assertEqual(f[b'1'], b'a')
@@ -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')