mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
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:
parent
43153e4d49
commit
4fc7942118
3 changed files with 24 additions and 3 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue