aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_dbm_dumb.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2018-02-05 22:47:31 +0200
committerGitHub <noreply@github.com>2018-02-05 22:47:31 +0200
commit6c85efa5a66d7b254aa22a39d47f36c040d7a04e (patch)
tree9f9c5f626364ac0b1a768a27a694c4ae0b4e6e6b /Lib/test/test_dbm_dumb.py
parentc309bcfb9fb295e70a235c461d9edcaa54c821d0 (diff)
downloadcpython-6c85efa5a66d7b254aa22a39d47f36c040d7a04e.tar.gz
cpython-6c85efa5a66d7b254aa22a39d47f36c040d7a04e.zip
bpo-32749: Make dbm.dumb databases more cosistent with other dbm databases. (#5497)
Diffstat (limited to 'Lib/test/test_dbm_dumb.py')
-rw-r--r--Lib/test/test_dbm_dumb.py35
1 files changed, 14 insertions, 21 deletions
diff --git a/Lib/test/test_dbm_dumb.py b/Lib/test/test_dbm_dumb.py
index 73f2a32a7b4..21f29af05d2 100644
--- a/Lib/test/test_dbm_dumb.py
+++ b/Lib/test/test_dbm_dumb.py
@@ -79,10 +79,10 @@ class DumbDBMTestCase(unittest.TestCase):
self.init_db()
f = dumbdbm.open(_fname, 'r')
self.read_helper(f)
- with self.assertWarnsRegex(DeprecationWarning,
+ with self.assertRaisesRegex(ValueError,
'The database is opened for reading only'):
f[b'g'] = b'x'
- with self.assertWarnsRegex(DeprecationWarning,
+ with self.assertRaisesRegex(ValueError,
'The database is opened for reading only'):
del f[b'a']
f.close()
@@ -241,37 +241,30 @@ class DumbDBMTestCase(unittest.TestCase):
pass
self.assertEqual(stdout.getvalue(), '')
- def test_warn_on_ignored_flags(self):
+ def test_missing_data(self):
for value in ('r', 'w'):
_delete_files()
- with self.assertWarnsRegex(DeprecationWarning,
- "The database file is missing, the "
- "semantics of the 'c' flag will "
- "be used."):
- f = dumbdbm.open(_fname, value)
- f.close()
+ with self.assertRaises(FileNotFoundError):
+ dumbdbm.open(_fname, value)
+ self.assertFalse(os.path.exists(_fname + '.dir'))
+ self.assertFalse(os.path.exists(_fname + '.bak'))
def test_missing_index(self):
with dumbdbm.open(_fname, 'n') as f:
pass
os.unlink(_fname + '.dir')
for value in ('r', 'w'):
- with self.assertWarnsRegex(DeprecationWarning,
- "The index file is missing, the "
- "semantics of the 'c' flag will "
- "be used."):
- f = dumbdbm.open(_fname, value)
- f.close()
- self.assertEqual(os.path.exists(_fname + '.dir'), value == 'w')
+ with self.assertRaises(FileNotFoundError):
+ dumbdbm.open(_fname, value)
+ self.assertFalse(os.path.exists(_fname + '.dir'))
self.assertFalse(os.path.exists(_fname + '.bak'))
def test_invalid_flag(self):
for flag in ('x', 'rf', None):
- with self.assertWarnsRegex(DeprecationWarning,
- "Flag must be one of "
- "'r', 'w', 'c', or 'n'"):
- f = dumbdbm.open(_fname, flag)
- f.close()
+ with self.assertRaisesRegex(ValueError,
+ "Flag must be one of "
+ "'r', 'w', 'c', or 'n'"):
+ dumbdbm.open(_fname, flag)
@unittest.skipUnless(hasattr(os, 'chmod'), 'test needs os.chmod()')
def test_readonly_files(self):