Issue #3389: Allow resolving dotted names for handlers in logging configuration files...
[python.git] / Lib / test / test_dbm.py
blob562b14f3db461b67a2d2732e990eb97e0bce37e7
1 from test import test_support
2 import unittest
3 import os
4 import random
5 import dbm
6 from dbm import error
8 class DbmTestCase(unittest.TestCase):
10 def setUp(self):
11 self.filename = test_support.TESTFN
12 self.d = dbm.open(self.filename, 'c')
13 self.d.close()
15 def tearDown(self):
16 for suffix in ['', '.pag', '.dir', '.db']:
17 test_support.unlink(self.filename + suffix)
19 def test_keys(self):
20 self.d = dbm.open(self.filename, 'c')
21 self.assert_(self.d.keys() == [])
22 self.d['a'] = 'b'
23 self.d['12345678910'] = '019237410982340912840198242'
24 self.d.keys()
25 self.assert_(self.d.has_key('a'))
26 self.d.close()
28 def test_modes(self):
29 for mode in ['r', 'rw', 'w', 'n']:
30 try:
31 self.d = dbm.open(self.filename, mode)
32 self.d.close()
33 except dbm.error:
34 self.fail()
36 def test_main():
37 test_support.run_unittest(DbmTestCase)
39 if __name__ == '__main__':
40 test_main()