summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_dbm_ndbm.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2018-04-29 12:45:03 (GMT)
committerGitHub <noreply@github.com>2018-04-29 12:45:03 (GMT)
commit70af06cdc4e8fbee0b9d7d46bdc193097d4bc71f (patch)
tree1f611083a5a5379c91916c1de6b332408cef4322 /Lib/test/test_dbm_ndbm.py
parent2e38cc39330bd7f3003652869b644110a97a78d8 (diff)
downloadcpython-70af06cdc4e8fbee0b9d7d46bdc193097d4bc71f.zip
cpython-70af06cdc4e8fbee0b9d7d46bdc193097d4bc71f.tar.gz
cpython-70af06cdc4e8fbee0b9d7d46bdc193097d4bc71f.tar.bz2
bpo-31026: Fix test_dbm if dbm.ndbm is build with Berkeley DB. (GH-6632)
Diffstat (limited to 'Lib/test/test_dbm_ndbm.py')
-rw-r--r--Lib/test/test_dbm_ndbm.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_dbm_ndbm.py b/Lib/test/test_dbm_ndbm.py
index f921167..49b88f5 100644
--- a/Lib/test/test_dbm_ndbm.py
+++ b/Lib/test/test_dbm_ndbm.py
@@ -36,6 +36,20 @@ class DbmTestCase(unittest.TestCase):
self.assertEqual(self.d[b'xxx'], b'foo')
self.d.close()
+ def test_empty_value(self):
+ if dbm.ndbm.library == 'Berkeley DB':
+ self.skipTest("Berkeley DB doesn't distinguish the empty value "
+ "from the absent one")
+ self.d = dbm.ndbm.open(self.filename, 'c')
+ self.assertEqual(self.d.keys(), [])
+ self.d['empty'] = ''
+ self.assertEqual(self.d.keys(), [b'empty'])
+ self.assertIn(b'empty', self.d)
+ self.assertEqual(self.d[b'empty'], b'')
+ self.assertEqual(self.d.get(b'empty'), b'')
+ self.assertEqual(self.d.setdefault(b'empty'), b'')
+ self.d.close()
+
def test_modes(self):
for mode in ['r', 'rw', 'w', 'n']:
try: