Esempio n. 1
0
def test_Cache():
    c = utils.Cache()

    c[5] = "Spam"
    assert 5 in c
    assert c[5] == "Spam"
    assert 6 not in c
Esempio n. 2
0
def test_Cache_evict():
    c = utils.Cache(2)
    c[5] = "a"
    c[6] = "b"
    c[7] = "c"
    assert set(c.keys()) == {6, 7}
    assert c[6] == "b"
    assert c[7] == "c"

    c[8] = "d"
    assert set(c.keys()) == {7, 8}
    assert c[7] == "c"

    c[9] = "e"
    assert set(c.keys()) == {7, 9}