mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-30 06:49:24 +01:00
Added PersistentDictionary.flush.
This commit is contained in:
parent
b9434a23a6
commit
7d960ca4c6
@ -368,3 +368,5 @@ class PersistentDictionary(dict):
|
||||
fd = file(self.filename, 'w')
|
||||
fd.write(repr(self))
|
||||
fd.close()
|
||||
|
||||
flush = close
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user