Back to index

python3.2  3.2.2
Public Member Functions | Static Private Attributes
test.test_dbm.AnyDBMTestCase Class Reference

List of all members.

Public Member Functions

def init_db
def keys_helper
def test_error
def test_anydbm_not_existing
def test_anydbm_creation
def test_anydbm_creation_n_file_exists_with_invalid_contents
def test_anydbm_modification
def test_anydbm_read
def test_anydbm_keys
def test_anydbm_access
def read_helper
def tearDown
def setUp

Static Private Attributes

dictionary _dict

Detailed Description

Definition at line 37 of file test_dbm.py.


Member Function Documentation

Definition at line 47 of file test_dbm.py.

00047 
00048     def init_db(self):
00049         f = dbm.open(_fname, 'n')
00050         for k in self._dict:
00051             f[k.encode("ascii")] = self._dict[k]
00052         f.close()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 53 of file test_dbm.py.

00053 
00054     def keys_helper(self, f):
00055         keys = sorted(k.decode("ascii") for k in f.keys())
00056         dkeys = sorted(self._dict.keys())
00057         self.assertEqual(keys, dkeys)
00058         return keys

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 108 of file test_dbm.py.

00108 
00109     def read_helper(self, f):
00110         keys = self.keys_helper(f)
00111         for key in self._dict:
00112             self.assertEqual(self._dict[key], f[key.encode("ascii")])

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 116 of file test_dbm.py.

00116 
00117     def setUp(self):
00118         dbm._defaultmod = self.module
00119         delete_files()
00120 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 113 of file test_dbm.py.

00113 
00114     def tearDown(self):
00115         delete_files()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 100 of file test_dbm.py.

00100 
00101     def test_anydbm_access(self):
00102         self.init_db()
00103         f = dbm.open(_fname, 'r')
00104         key = "a".encode("ascii")
00105         self.assertIn(key, f)
00106         assert(f[key] == b"Python:")
00107         f.close()

Here is the call graph for this function:

Definition at line 65 of file test_dbm.py.

00065 
00066     def test_anydbm_creation(self):
00067         f = dbm.open(_fname, 'c')
00068         self.assertEqual(list(f.keys()), [])
00069         for key in self._dict:
00070             f[key.encode("ascii")] = self._dict[key]
00071         self.read_helper(f)
00072         f.close()

Here is the call graph for this function:

Definition at line 73 of file test_dbm.py.

00073 
00074     def test_anydbm_creation_n_file_exists_with_invalid_contents(self):
00075         with open(_fname, "w") as w:
00076             pass # create an empty file
00077 
00078         f = dbm.open(_fname, 'n')
00079         self.addCleanup(f.close)
00080         self.assertEqual(len(f), 0)

Here is the call graph for this function:

Definition at line 94 of file test_dbm.py.

00094 
00095     def test_anydbm_keys(self):
00096         self.init_db()
00097         f = dbm.open(_fname, 'r')
00098         keys = self.keys_helper(f)
00099         f.close()

Here is the call graph for this function:

Definition at line 81 of file test_dbm.py.

00081 
00082     def test_anydbm_modification(self):
00083         self.init_db()
00084         f = dbm.open(_fname, 'c')
00085         self._dict['g'] = f[b'g'] = b"indented"
00086         self.read_helper(f)
00087         f.close()

Here is the call graph for this function:

Definition at line 62 of file test_dbm.py.

00062 
00063     def test_anydbm_not_existing(self):
00064         self.assertRaises(dbm.error, dbm.open, _fname)

Here is the call graph for this function:

Definition at line 88 of file test_dbm.py.

00088 
00089     def test_anydbm_read(self):
00090         self.init_db()
00091         f = dbm.open(_fname, 'r')
00092         self.read_helper(f)
00093         f.close()

Here is the call graph for this function:

Definition at line 59 of file test_dbm.py.

00059 
00060     def test_error(self):
00061         self.assertTrue(issubclass(self.module.error, IOError))

Here is the call graph for this function:


Member Data Documentation

Initial value:
{'0': b'',
             'a': b'Python:',
             'b': b'Programming',
             'c': b'the',
             'd': b'way',
             'f': b'Guido',
             'g': b'intended',
             }

Definition at line 38 of file test_dbm.py.


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