summaryrefslogtreecommitdiff
path: root/Lib/test/test_dbm.py
diff options
context:
space:
mode:
authorbriancurtin <brian.curtin@gmail.com>2011-03-14 15:35:35 -0400
committerbriancurtin <brian.curtin@gmail.com>2011-03-14 15:35:35 -0400
commit94eceeb89c153d8bf77dc194f8896a66cc25519a (patch)
treeaf14d0e536dbb4b85a5dcb7a3552b1b0146450a6 /Lib/test/test_dbm.py
parent250324952e63a51fe885d457d207082f249bbefd (diff)
downloadcpython-git-94eceeb89c153d8bf77dc194f8896a66cc25519a.tar.gz
Fix #11491. When dbm.open was called with a file which already exists and
the "flag" argument is "n", dbm.error was being raised. As documented, dbm.open(...,flag='n') will now "Always create a new, empty database, open for reading and writing", regardless of a previous file existing.
Diffstat (limited to 'Lib/test/test_dbm.py')
-rw-r--r--Lib/test/test_dbm.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_dbm.py b/Lib/test/test_dbm.py
index 818be453f4..ce48cfd5ce 100644
--- a/Lib/test/test_dbm.py
+++ b/Lib/test/test_dbm.py
@@ -70,6 +70,14 @@ class AnyDBMTestCase(unittest.TestCase):
self.read_helper(f)
f.close()
+ def test_anydbm_creation_n_file_exists_with_invalid_contents(self):
+ with open(_fname, "w") as w:
+ pass # create an empty file
+
+ f = dbm.open(_fname, 'n')
+ self.addCleanup(f.close)
+ self.assertEqual(len(f), 0)
+
def test_anydbm_modification(self):
self.init_db()
f = dbm.open(_fname, 'c')