mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-31026: Fix test_dbm if dbm.ndbm is build with Berkeley DB. (GH-6632)
This commit is contained in:
parent
2e38cc3933
commit
70af06cdc4
2 changed files with 29 additions and 2 deletions
|
@ -38,8 +38,7 @@ def delete_files():
|
|||
|
||||
|
||||
class AnyDBMTestCase:
|
||||
_dict = {'0': b'',
|
||||
'a': b'Python:',
|
||||
_dict = {'a': b'Python:',
|
||||
'b': b'Programming',
|
||||
'c': b'the',
|
||||
'd': b'way',
|
||||
|
@ -109,6 +108,20 @@ class AnyDBMTestCase:
|
|||
keys = self.keys_helper(f)
|
||||
f.close()
|
||||
|
||||
def test_empty_value(self):
|
||||
if getattr(dbm._defaultmod, 'library', None) == 'Berkeley DB':
|
||||
self.skipTest("Berkeley DB doesn't distinguish the empty value "
|
||||
"from the absent one")
|
||||
f = dbm.open(_fname, 'c')
|
||||
self.assertEqual(f.keys(), [])
|
||||
f[b'empty'] = b''
|
||||
self.assertEqual(f.keys(), [b'empty'])
|
||||
self.assertIn(b'empty', f)
|
||||
self.assertEqual(f[b'empty'], b'')
|
||||
self.assertEqual(f.get(b'empty'), b'')
|
||||
self.assertEqual(f.setdefault(b'empty'), b'')
|
||||
f.close()
|
||||
|
||||
def test_anydbm_access(self):
|
||||
self.init_db()
|
||||
f = dbm.open(_fname, 'r')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue