aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_dbm_dumb.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-12-07 11:11:12 +0200
committerSerhiy Storchaka <storchaka@gmail.com>2016-12-07 11:11:12 +0200
commit4fc7942118f017c214534d29b18f2f844e68c8cf (patch)
tree96d01af875793a86f0c33cd3d08ff04d9e9586af /Lib/test/test_dbm_dumb.py
parent43153e4d49100b46a603afa8deeca415eb18d180 (diff)
downloadcpython-4fc7942118f017c214534d29b18f2f844e68c8cf.tar.gz
cpython-4fc7942118f017c214534d29b18f2f844e68c8cf.zip
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.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_dbm_dumb.py b/Lib/test/test_dbm_dumb.py
index df531d64e48..c2703d7e0b6 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,