'DirDBM: test recovery from directory after a faked crash'

def testRecovery(self):

    k = self.dbm._encode('key1')
    with self.path.child((k + '.rpl')).open(mode='wb') as f:
        f.write('value')
    k2 = self.dbm._encode('key2')
    with self.path.child(k2).open(mode='wb') as f:
        f.write('correct')
    with self.path.child((k2 + '.rpl')).open(mode='wb') as f:
        f.write('wrong')
    with self.path.child('aa.new').open(mode='wb') as f:
        f.write('deleted')
    dbm = dirdbm.DirDBM(self.path.path)
    self.assertEqual(dbm['key1'], 'value')
    self.assertEqual(dbm['key2'], 'correct')
    self.assertFalse(self.path.globChildren('*.new'))
    self.assertFalse(self.path.globChildren('*.rpl'))
