

def testDbm(self):
    d = self.dbm
    keys = []
    values = []
    for (k, v) in self.items:
        d[k] = v
        keys.append(k)
        values.append(v)
    keys.sort()
    values.sort()
    for (k, v) in self.items:
        assert d.has_key(k), 'has_key() failed'
        assert (d[k] == v), 'database has wrong value'
    try:
        d['XXX']
    except KeyError:
        pass
    else:
        assert 0, "didn't raise KeyError on non-existent key"
    dbkeys = list(d.keys())
    dbvalues = list(d.values())
    dbitems = list(d.items())
    dbkeys.sort()
    dbvalues.sort()
    dbitems.sort()
    items = list(self.items)
    items.sort()
    assert (keys == dbkeys), (".keys() output didn't match: %s != %s" % (repr(keys), repr(dbkeys)))
    assert (values == dbvalues), (".values() output didn't match: %s != %s" % (repr(values), repr(dbvalues)))
    assert (items == dbitems), ("items() didn't match: %s != %s" % (repr(items), repr(dbitems)))
    copyPath = self.mktemp()
    d2 = d.copyTo(copyPath)
    copykeys = list(d.keys())
    copyvalues = list(d.values())
    copyitems = list(d.items())
    copykeys.sort()
    copyvalues.sort()
    copyitems.sort()
    assert (dbkeys == copykeys), (".copyTo().keys() didn't match: %s != %s" % (repr(self), repr(copykeys)))
    assert (dbvalues == copyvalues), (".copyTo().values() didn't match: %s != %s" % (repr(dbvalues), repr(copyvalues)))
    assert (dbitems == copyitems), (".copyTo().items() didn't match: %s != %s" % (repr(dbkeys), repr(copyitems)))
    d2.clear()
    assert (len(d2.keys()) == len(d2.values()) == len(d2.items()) == 0), '.clear() failed'
    shutil.rmtree(copyPath)
    for (k, v) in self.items:
        del d[k]
        assert (not d.has_key(k)), 'has_key() even though we deleted it'
    assert (len(d.keys()) == 0), 'database has keys'
    assert (len(d.values()) == 0), 'database has values'
    assert (len(d.items()) == 0), 'database has items'

dataset/ETHPy150Open kuri65536/python-for-android/python-modules/twisted/twisted/test/test_dirdbm.py DirDbmTestCase.testDbm/VarMisuse@353/505 `dbkeys`->`self`