Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
test.test_dbm.WhichDBTestCase Class Reference

List of all members.

Public Member Functions

def __init__
def test_whichdb
def tearDown
def setUp
def test_keys

Public Attributes

 filename
 d

Detailed Description

Definition at line 121 of file test_dbm.py.


Constructor & Destructor Documentation

def test.test_dbm.WhichDBTestCase.__init__ (   self,
  args 
)

Definition at line 123 of file test_dbm.py.

00123 
00124     def __init__(self, *args):
00125         unittest.TestCase.__init__(self, *args)

Here is the caller graph for this function:


Member Function Documentation

Definition at line 151 of file test_dbm.py.

00151 
00152     def setUp(self):
00153         delete_files()
00154         self.filename = test.support.TESTFN
00155         self.d = dbm.open(self.filename, 'c')
00156         self.d.close()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 148 of file test_dbm.py.

00148 
00149     def tearDown(self):
00150         delete_files()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 157 of file test_dbm.py.

00157 
00158     def test_keys(self):
00159         self.d = dbm.open(self.filename, 'c')
00160         self.assertEqual(self.d.keys(), [])
00161         a = [(b'a', b'b'), (b'12345678910', b'019237410982340912840198242')]
00162         for k, v in a:
00163             self.d[k] = v
00164         self.assertEqual(sorted(self.d.keys()), sorted(k for (k, v) in a))
00165         for k, v in a:
00166             self.assertIn(k, self.d)
00167             self.assertEqual(self.d[k], v)
00168         self.assertNotIn(b'xxx', self.d)
00169         self.assertRaises(KeyError, lambda: self.d[b'xxx'])
00170         self.d.close()
00171 

Here is the call graph for this function:

Definition at line 126 of file test_dbm.py.

00126 
00127     def test_whichdb(self):
00128         for module in dbm_iterator():
00129             # Check whether whichdb correctly guesses module name
00130             # for databases opened with "module" module.
00131             # Try with empty files first
00132             name = module.__name__
00133             if name == 'dbm.dumb':
00134                 continue   # whichdb can't support dbm.dumb
00135             delete_files()
00136             f = module.open(_fname, 'c')
00137             f.close()
00138             self.assertEqual(name, dbm.whichdb(_fname))
00139             # Now add a key
00140             f = module.open(_fname, 'w')
00141             f[b"1"] = b"1"
00142             # and test that we can find it
00143             self.assertIn(b"1", f)
00144             # and read it
00145             self.assertTrue(f[b"1"] == b"1")
00146             f.close()
00147             self.assertEqual(name, dbm.whichdb(_fname))

Here is the call graph for this function:


Member Data Documentation

Definition at line 154 of file test_dbm.py.

Definition at line 153 of file test_dbm.py.


The documentation for this class was generated from the following file: