diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2018-04-29 09:38:06 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-29 09:38:06 (GMT) |
commit | 2e38cc39330bd7f3003652869b644110a97a78d8 (patch) | |
tree | 5f1a63d9c23d486cdbf8a588e442d3c307917b07 /Lib/test/test_dbm_gnu.py | |
parent | 577948329976985ea9bef23d9a6c3dd7108211bf (diff) | |
download | cpython-2e38cc39330bd7f3003652869b644110a97a78d8.zip cpython-2e38cc39330bd7f3003652869b644110a97a78d8.tar.gz cpython-2e38cc39330bd7f3003652869b644110a97a78d8.tar.bz2 |
bpo-33383: Fix crash in get() of the dbm.ndbm database object. (#6630)
Diffstat (limited to 'Lib/test/test_dbm_gnu.py')
-rw-r--r-- | Lib/test/test_dbm_gnu.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/test/test_dbm_gnu.py b/Lib/test/test_dbm_gnu.py index d96df92..463d343 100644 --- a/Lib/test/test_dbm_gnu.py +++ b/Lib/test/test_dbm_gnu.py @@ -32,9 +32,12 @@ class TestGdbm(unittest.TestCase): self.assertIn(key, key_set) key_set.remove(key) key = self.g.nextkey(key) - self.assertRaises(KeyError, lambda: self.g['xxx']) # get() and setdefault() work as in the dict interface + self.assertEqual(self.g.get(b'a'), b'b') + self.assertIsNone(self.g.get(b'xxx')) self.assertEqual(self.g.get(b'xxx', b'foo'), b'foo') + with self.assertRaises(KeyError): + self.g['xxx'] self.assertEqual(self.g.setdefault(b'xxx', b'foo'), b'foo') self.assertEqual(self.g[b'xxx'], b'foo') |