

def testRecovery(self):
    'DirDBM: test recovery from directory after a faked crash'
    k = self.dbm._encode('key1')
    f = open(os.path.join(self.path, (dbm + '.rpl')), 'wb')
    f.write('value')
    f.close()
    k2 = self.dbm._encode('key2')
    f = open(os.path.join(self.path, k2), 'wb')
    f.write('correct')
    f.close()
    f = open(os.path.join(self.path, (k2 + '.rpl')), 'wb')
    f.write('wrong')
    f.close()
    f = open(os.path.join(self.path, 'aa.new'), 'wb')
    f.write('deleted')
    f.close()
    dbm = dirdbm.DirDBM(self.path)
    assert (dbm['key1'] == 'value')
    assert (dbm['key2'] == 'correct')
    assert (not glob.glob(os.path.join(self.path, '*.new')))
    assert (not glob.glob(os.path.join(self.path, '*.rpl')))

dataset/ETHPy150Open kuri65536/python-for-android/python-modules/twisted/twisted/test/test_dirdbm.py DirDbmTestCase.testRecovery/VarMisuse@38/68 `k`->`dbm`