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

Method test_limited_size_cache

tests/test_loader.py:84–96  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

82 assert env.get_template("foo") is not env.get_template("foo")
83
84 def test_limited_size_cache(self):
85 mapping = {"one": "foo", "two": "bar", "three": "baz"}
86 loader = loaders.DictLoader(mapping)
87 env = Environment(loader=loader, cache_size=2)
88 t1 = env.get_template("one")
89 t2 = env.get_template("two")
90 assert t2 is env.get_template("two")
91 assert t1 is env.get_template("one")
92 env.get_template("three")
93 loader_ref = weakref.ref(loader)
94 assert (loader_ref, "one") in env.cache
95 assert (loader_ref, "two") not in env.cache
96 assert (loader_ref, "three") in env.cache
97
98 def test_cache_loader_change(self):
99 loader1 = loaders.DictLoader({"foo": "one"})

Callers

nothing calls this directly

Calls 3

get_templateMethod · 0.95
EnvironmentClass · 0.90
refMethod · 0.80

Tested by

no test coverage detected