diff options
author | Benjamin Peterson <benjamin@python.org> | 2008-10-11 00:49:57 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2008-10-11 00:49:57 (GMT) |
commit | f10a79aad4e2fc62d2c3675e89f873b22b185e7b (patch) | |
tree | 06b042ca03a71663d26ad95949807d1bd2472bf4 /Lib/test/test_dbm.py | |
parent | 2d8dcdcb06005858e87eded012ceff10920445b7 (diff) | |
download | cpython-f10a79aad4e2fc62d2c3675e89f873b22b185e7b.zip cpython-f10a79aad4e2fc62d2c3675e89f873b22b185e7b.tar.gz cpython-f10a79aad4e2fc62d2c3675e89f873b22b185e7b.tar.bz2 |
merge from trunk
Diffstat (limited to 'Lib/test/test_dbm.py')
-rw-r--r-- | Lib/test/test_dbm.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_dbm.py b/Lib/test/test_dbm.py index ee82dd2..9f929f4 100644 --- a/Lib/test/test_dbm.py +++ b/Lib/test/test_dbm.py @@ -140,6 +140,23 @@ class WhichDBTestCase(unittest.TestCase): def setUp(self): delete_files() + self.filename = test.support.TESTFN + self.d = dbm.open(self.filename, 'c') + self.d.close() + + def test_keys(self): + self.d = dbm.open(self.filename, 'c') + self.assertEqual(self.d.keys(), []) + a = [(b'a', b'b'), (b'12345678910', b'019237410982340912840198242')] + for k, v in a: + self.d[k] = v + self.assertEqual(sorted(self.d.keys()), sorted(k for (k, v) in a)) + for k, v in a: + self.assert_(k in self.d) + self.assertEqual(self.d[k], v) + self.assert_('xxx' not in self.d) + self.assertRaises(KeyError, lambda: self.d['xxx']) + self.d.close() def test_main(): |