예제 #1
0
def test_cache():
    c = cache.DictCache()
    key = (0, 1)
    value = 'value'

    assert c.get(key) is None
    assert c.hits == 0
    assert c.misses == 1
    assert c.info() == (0, 1, 0)
    assert c.size() == 0

    c.set(key, value)

    assert c.get(key) == value
    assert c.hits == 1
    assert c.misses == 1
    assert c.info() == (1, 1, 1)
    assert c.size() == 1

    c.clear()
    assert c.size() == 0
    assert c.hits == 0
    assert c.misses == 0
예제 #2
0
def test_cache_key_generation():
    c = cache.DictCache()
    assert c.key('arg', _prefix='CONSTANT') == ('CONSTANT', 'arg')
예제 #3
0
 def __init__(self):
     self.repertoire_cache = cache.DictCache()
예제 #4
0
 def __init__(self):
     self.my_cache = cache.DictCache()
예제 #5
0
파일: test_cache.py 프로젝트: wesmith/pyphi
def test_cache_key_generation():
    c = cache.DictCache()
    assert c.key("arg", _prefix="CONSTANT") == ("CONSTANT", "arg")