MCPcopy
hub / github.com/pallets/jinja / test_items

Method test_items

tests/test_utils.py:78–95  ·  view source on GitHub ↗

Test various items, keys, values and iterators of LRUCache.

(self)

Source from the content-addressed store, hash-verified

76 assert sorted(repr(d)) == sorted("<LRUCache {'a': 1, 'b': 2, 'c': 3}>")
77
78 def test_items(self):
79 """Test various items, keys, values and iterators of LRUCache."""
80 d = LRUCache(3)
81 d["a"] = 1
82 d["b"] = 2
83 d["c"] = 3
84 assert d.items() == [("c", 3), ("b", 2), ("a", 1)]
85 assert d.keys() == ["c", "b", "a"]
86 assert d.values() == [3, 2, 1]
87 assert list(reversed(d)) == ["a", "b", "c"]
88
89 # Change the cache a little
90 d["b"]
91 d["a"] = 4
92 assert d.items() == [("a", 4), ("b", 2), ("c", 3)]
93 assert d.keys() == ["a", "b", "c"]
94 assert d.values() == [4, 2, 3]
95 assert list(reversed(d)) == ["c", "b", "a"]
96
97 def test_setdefault(self):
98 d = LRUCache(3)

Callers

nothing calls this directly

Calls 4

itemsMethod · 0.95
keysMethod · 0.95
valuesMethod · 0.95
LRUCacheClass · 0.90

Tested by

no test coverage detected