1 from test
import test_support
3 dbm
= test_support
.import_module('dbm')
5 class DbmTestCase(unittest
.TestCase
):
8 self
.filename
= test_support
.TESTFN
9 self
.d
= dbm
.open(self
.filename
, 'c')
13 for suffix
in ['', '.pag', '.dir', '.db']:
14 test_support
.unlink(self
.filename
+ suffix
)
17 self
.d
= dbm
.open(self
.filename
, 'c')
18 self
.assertEqual(self
.d
.keys(), [])
19 a
= [('a', 'b'), ('12345678910', '019237410982340912840198242')]
22 self
.assertEqual(sorted(self
.d
.keys()), sorted(k
for (k
, v
) in a
))
24 self
.assertTrue(k
in self
.d
)
25 self
.assertEqual(self
.d
[k
], v
)
26 self
.assertTrue('xxx' not in self
.d
)
27 self
.assertRaises(KeyError, lambda: self
.d
['xxx'])
31 for mode
in ['r', 'rw', 'w', 'n']:
33 self
.d
= dbm
.open(self
.filename
, mode
)
39 test_support
.run_unittest(DbmTestCase
)
41 if __name__
== '__main__':