Skip to content
Myr

test_lrucache.py

This file

Path

tests/test_lrucache.py

39 lines · 802 bytes · Python

Last changed by

Copyright switch to "The Jinja Team".Armin Ronacherbefore adoption62ccd1b

History of this file

Take it

1# -*- coding: utf-8 -*-2"""3    Tests the LRUCache4    ~~~~~~~~~~~~~~~~~~56    This module tests the LRU Cache78    :copyright: (c) 2009 by the Jinja Team.9    :license: BSD.10"""11import thread12import time13import random14import pickle15from jinja2.utils import LRUCache161718def test_simple():19    d = LRUCache(3)20    d["a"] = 121    d["b"] = 222    d["c"] = 323    d["a"]24    d["d"] = 425    assert len(d) == 326    assert 'a' in d and 'c' in d and 'd' in d and 'b' not in d272829def test_pickleable():30    cache = LRUCache(2)31    cache["foo"] = 4232    cache["bar"] = 2333    cache["foo"]3435    for protocol in range(3):36        copy = pickle.loads(pickle.dumps(cache, protocol))37        assert copy.capacity == cache.capacity38        assert copy._mapping == cache._mapping39        assert copy._queue == cache._queue