diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-12-07 11:11:12 +0200 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-12-07 11:11:12 +0200 |
commit | 9fd6824b7c9fdde8c178411b70d2f19b1371e523 (patch) | |
tree | 9130c8c0cd12413d2a395297b566f307d68ae0bb /Lib/test/test_dbm_dumb.py | |
parent | 469d2e4c4fb0691727246a962a9b17980854cd1c (diff) | |
download | cpython-9fd6824b7c9fdde8c178411b70d2f19b1371e523.tar.gz |
Issue #28847: A deprecation warning is now emitted if the index file is missed
and recreated in the 'r' and 'w' modes (will be an error in future Python
releases).
Diffstat (limited to 'Lib/test/test_dbm_dumb.py')
-rw-r--r-- | Lib/test/test_dbm_dumb.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_dbm_dumb.py b/Lib/test/test_dbm_dumb.py index df531d64e4..c2703d7e0b 100644 --- a/Lib/test/test_dbm_dumb.py +++ b/Lib/test/test_dbm_dumb.py @@ -252,6 +252,20 @@ class DumbDBMTestCase(unittest.TestCase): f = dumbdbm.open(_fname, value) f.close() + 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') + self.assertFalse(os.path.exists(_fname + '.bak')) + def test_invalid_flag(self): for flag in ('x', 'rf', None): with self.assertWarnsRegex(DeprecationWarning, |