diff --git a/src/structures.py b/src/structures.py index 090680d11..0919a28da 100644 --- a/src/structures.py +++ b/src/structures.py @@ -368,3 +368,5 @@ class PersistentDictionary(dict): fd = file(self.filename, 'w') fd.write(repr(self)) fd.close() + + flush = close diff --git a/test/test_structures.py b/test/test_structures.py index aeddc70da..737411eca 100644 --- a/test/test_structures.py +++ b/test/test_structures.py @@ -582,11 +582,23 @@ class PersistentDictionaryTestCase(unittest.TestCase): d['foo'] = 'bar' d[1] = 2 d.close() - d1 = PersistentDictionary('test.dict') + d2 = PersistentDictionary('test.dict') self.failUnless('foo' in d) self.assertEqual(d['foo'], 'bar') self.failUnless(1 in d) self.assertEqual(d[1], 2) + self.failUnless('foo' in d2) + self.assertEqual(d2['foo'], 'bar') + self.failUnless(1 in d2) + self.assertEqual(d2[1], 2) + + def testFlush(self): + d = PersistentDictionary('test.dict') + d[1] = 2 + d.flush() + d2 = PersistentDictionary('test.dict') + self.failUnless(1 in d2) + self.assertEqual(d2[1], 2) # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: