mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Close #19282: Native context management in dbm
This commit is contained in:
parent
eb8ea265ba
commit
c610aba1ed
8 changed files with 101 additions and 16 deletions
|
@ -184,6 +184,19 @@ class DumbDBMTestCase(unittest.TestCase):
|
|||
self.assertEqual(expected, got)
|
||||
f.close()
|
||||
|
||||
def test_context_manager(self):
|
||||
with dumbdbm.open(_fname, 'c') as db:
|
||||
db["dumbdbm context manager"] = "context manager"
|
||||
|
||||
with dumbdbm.open(_fname, 'r') as db:
|
||||
self.assertEqual(list(db.keys()), [b"dumbdbm context manager"])
|
||||
|
||||
# This currently just raises AttributeError rather than a specific
|
||||
# exception like the GNU or NDBM based implementations. See
|
||||
# http://bugs.python.org/issue19385 for details.
|
||||
with self.assertRaises(Exception):
|
||||
db.keys()
|
||||
|
||||
def tearDown(self):
|
||||
_delete_files()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue