mirror of
https://github.com/python/cpython.git
synced 2025-10-17 04:08:28 +00:00
gh-107122: Add clear method to dbm.gdbm.module (gh-107127)
This commit is contained in:
parent
e59da0c4f2
commit
b273837fea
5 changed files with 77 additions and 1 deletions
|
@ -192,6 +192,20 @@ class TestGdbm(unittest.TestCase):
|
|||
def test_open_with_pathlib_bytes_path(self):
|
||||
gdbm.open(FakePath(os.fsencode(filename)), "c").close()
|
||||
|
||||
def test_clear(self):
|
||||
kvs = [('foo', 'bar'), ('1234', '5678')]
|
||||
with gdbm.open(filename, 'c') as db:
|
||||
for k, v in kvs:
|
||||
db[k] = v
|
||||
self.assertIn(k, db)
|
||||
self.assertEqual(len(db), len(kvs))
|
||||
|
||||
db.clear()
|
||||
for k, v in kvs:
|
||||
self.assertNotIn(k, db)
|
||||
self.assertEqual(len(db), 0)
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue