diff options
author | Nick Coghlan <ncoghlan@gmail.com> | 2013-11-17 05:59:51 (GMT) |
---|---|---|
committer | Nick Coghlan <ncoghlan@gmail.com> | 2013-11-17 05:59:51 (GMT) |
commit | c610aba1ed57a30104a254ccd1f9fe07d02b1334 (patch) | |
tree | de690ad2f0b0f9cda831d66f026e5494a77882c5 /Lib/test/test_dbm_dumb.py | |
parent | eb8ea265bac16844efebe4f42d3c674527a66988 (diff) | |
download | cpython-c610aba1ed57a30104a254ccd1f9fe07d02b1334.zip cpython-c610aba1ed57a30104a254ccd1f9fe07d02b1334.tar.gz cpython-c610aba1ed57a30104a254ccd1f9fe07d02b1334.tar.bz2 |
Close #19282: Native context management in dbm
Diffstat (limited to 'Lib/test/test_dbm_dumb.py')
-rw-r--r-- | Lib/test/test_dbm_dumb.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_dbm_dumb.py b/Lib/test/test_dbm_dumb.py index 208bc4c..9fd8cde 100644 --- a/Lib/test/test_dbm_dumb.py +++ b/Lib/test/test_dbm_dumb.py @@ -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() |