@tests.test
def inc_dec():
    """Tests inc() and dec() methods."""
    try:
        mc = os.environ['VOLATILETESTS_MEMCACHED']
    except __HOLE__:
        print 'VOLATILETESTS_MEMCACHED is not set; skipped'
        return
    mc = MemcachedCache([mc], key_prefix='volatiletests_%s' % time.time())
    def tpl(method, r1, r2):
        unit, store = make_unit(mc)
        op = getattr(unit, method)
        key = method + 'num'
        assert unit.get(key) is None
        assert store.get(unit.subkey(key)) is None
        for ref in unit.subkeys_transaction:
            assert ref() is None or key not in ref()
        unit.set(key, 5)
        op(key)
        assert unit.get(key) == r1
        assert store.get(unit.subkey(key)) == r1
        for ref in unit.subkeys_transaction:
            assert key in ref()
        op(key, 2)
        assert unit.get(key) == r2
        assert store.get(unit.subkey(key)) == r2
        for ref in unit.subkeys_transaction:
            assert key in ref()
    tpl('inc', 6, 8)
    tpl('dec', 4, 2)
dataset/ETHPy150Open StyleShare/flask-volatile/volatiletests/unit.py/inc_dec