test_bytecode_cache.py
This file
Path
tests/test_bytecode_cache.py
77 lines · 1.9 KiB · Python
Last changed by
Merge branch '2.11.x'David Lordbefore adoptione08dadd
History of this fileTake it
The walk stopped after 200 commits: lines older than fe3dada point at it.
Merge pull request #787 from SabujXi/patch-1David Lordbefore adoptionfe3dada
lines 1–2why, one step back1import pytest2Merge pull request #1133 from pallets/revert-renameDavid Lordbefore adoption15337f7
lines 3–7why, one step back3from jinja2 import Environment4from jinja2.bccache import Bucket5from jinja2.bccache import FileSystemBytecodeCache6from jinja2.bccache import MemcachedBytecodeCache7from jinja2.exceptions import TemplateNotFoundMerge pull request #787 from SabujXi/patch-1David Lordbefore adoptionfe3dada
lines 8–10why, one step back8910@pytest.fixtureisolate bytecode cache testsDavid Lordbefore adoptiond312609
lines 11–13why, one step back11def env(package_loader, tmp_path):12 bytecode_cache = FileSystemBytecodeCache(str(tmp_path))13 return Environment(loader=package_loader, bytecode_cache=bytecode_cache)Merge pull request #787 from SabujXi/patch-1David Lordbefore adoptionfe3dada
lines 14–15why, one step back1415Merge pull request #1136 from pallets/drop-python2David Lordbefore adoption3915eb5
line 16why, one step back16class TestByteCodeCache:Merge pull request #787 from SabujXi/patch-1David Lordbefore adoptionfe3dada
line 17why, one step back17 def test_simple(self, env):Merge pull request #1125 from pallets/styleDavid Lordbefore adoption42d4a4e
lines 18–20why, one step back18 tmpl = env.get_template("test.html")19 assert tmpl.render().strip() == "BAR"20 pytest.raises(TemplateNotFound, env.get_template, "missing.html")Merge pull request #787 from SabujXi/patch-1David Lordbefore adoptionfe3dada
lines 21–22why, one step back2122Merge pull request #1136 from pallets/drop-python2David Lordbefore adoption3915eb5
line 23why, one step back23class MockMemcached:Merge pull request #787 from SabujXi/patch-1David Lordbefore adoptionfe3dada
lines 24–45why, one step back24 class Error(Exception):25 pass2627 key = None28 value = None29 timeout = None3031 def get(self, key):32 return self.value3334 def set(self, key, value, timeout=None):35 self.key = key36 self.value = value37 self.timeout = timeout3839 def get_side_effect(self, key):40 raise self.Error()4142 def set_side_effect(self, *args):43 raise self.Error()4445Merge pull request #1136 from pallets/drop-python2David Lordbefore adoption3915eb5
line 46why, one step back46class TestMemcachedBytecodeCache:Merge pull request #787 from SabujXi/patch-1David Lordbefore adoptionfe3dada
lines 47–50why, one step back47 def test_dump_load(self):48 memcached = MockMemcached()49 m = MemcachedBytecodeCache(memcached)50Merge pull request #1125 from pallets/styleDavid Lordbefore adoption42d4a4e
lines 51–52why, one step back51 b = Bucket(None, "key", "")52 b.code = "code"Merge pull request #787 from SabujXi/patch-1David Lordbefore adoptionfe3dada
line 53why, one step back53 m.dump_bytecode(b)Merge pull request #1133 from pallets/revert-renameDavid Lordbefore adoption15337f7
line 54why, one step back54 assert memcached.key == "jinja2/bytecode/key"Merge pull request #787 from SabujXi/patch-1David Lordbefore adoptionfe3dada
line 55why, one step back55Merge pull request #1125 from pallets/styleDavid Lordbefore adoption42d4a4e
line 56why, one step back56 b = Bucket(None, "key", "")Merge pull request #787 from SabujXi/patch-1David Lordbefore adoptionfe3dada
line 57why, one step back57 m.load_bytecode(b)Merge pull request #1125 from pallets/styleDavid Lordbefore adoption42d4a4e
line 58why, one step back58 assert b.code == "code"Merge pull request #787 from SabujXi/patch-1David Lordbefore adoptionfe3dada
lines 59–64why, one step back5960 def test_exception(self):61 memcached = MockMemcached()62 memcached.get = memcached.get_side_effect63 memcached.set = memcached.set_side_effect64 m = MemcachedBytecodeCache(memcached)Merge pull request #1125 from pallets/styleDavid Lordbefore adoption42d4a4e
lines 65–66why, one step back65 b = Bucket(None, "key", "")66 b.code = "code"Merge pull request #787 from SabujXi/patch-1David Lordbefore adoptionfe3dada
lines 67–77why, one step back6768 m.dump_bytecode(b)69 m.load_bytecode(b)7071 m.ignore_memcache_errors = False7273 with pytest.raises(MockMemcached.Error):74 m.dump_bytecode(b)7576 with pytest.raises(MockMemcached.Error):77 m.load_bytecode(b)