summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_dbm.py
diff options
context:
space:
mode:
authorHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>2008-10-07 18:10:47 (GMT)
committerHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>2008-10-07 18:10:47 (GMT)
commit39defbe6a9191d3054dca0903b4861f7adcfd68d (patch)
tree4ca595eedc6bd097c57b2188578193847ccf60f3 /Lib/test/test_dbm.py
parent7d9d7a265955d7a9988d7dff18b7e138910de8b2 (diff)
downloadcpython-39defbe6a9191d3054dca0903b4861f7adcfd68d.zip
cpython-39defbe6a9191d3054dca0903b4861f7adcfd68d.tar.gz
cpython-39defbe6a9191d3054dca0903b4861f7adcfd68d.tar.bz2
more intensive test on dbm.
Diffstat (limited to 'Lib/test/test_dbm.py')
-rwxr-xr-xLib/test/test_dbm.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/Lib/test/test_dbm.py b/Lib/test/test_dbm.py
index 562b14f..0541f86 100755
--- a/Lib/test/test_dbm.py
+++ b/Lib/test/test_dbm.py
@@ -1,9 +1,6 @@
from test import test_support
import unittest
-import os
-import random
import dbm
-from dbm import error
class DbmTestCase(unittest.TestCase):
@@ -18,11 +15,16 @@ class DbmTestCase(unittest.TestCase):
def test_keys(self):
self.d = dbm.open(self.filename, 'c')
- self.assert_(self.d.keys() == [])
- self.d['a'] = 'b'
- self.d['12345678910'] = '019237410982340912840198242'
- self.d.keys()
- self.assert_(self.d.has_key('a'))
+ self.assertEqual(self.d.keys(), [])
+ a = [('a', 'b'), ('12345678910', '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_modes(self):