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).
This commit is contained in:
Serhiy Storchaka 2016-12-07 11:11:12 +02:00
parent 43153e4d49
commit 4fc7942118
3 changed files with 24 additions and 3 deletions

View file

@ -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,