summaryrefslogtreecommitdiff
path: root/tests/test_bytecode_cache.py
blob: 42ff84002064425d2b2e8a52d48960e6fbce20f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# -*- coding: utf-8 -*-
"""
    jinja2.testsuite.bytecode_cache
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Test bytecode caching

    :copyright: (c) 2017 by the Jinja Team.
    :license: BSD, see LICENSE for more details.
"""
import pytest
from jinja2 import Environment
from jinja2.bccache import FileSystemBytecodeCache
from jinja2.exceptions import TemplateNotFound


@pytest.fixture
def env(package_loader):
    bytecode_cache = FileSystemBytecodeCache()
    return Environment(
        loader=package_loader,
        bytecode_cache=bytecode_cache,
    )


@pytest.mark.byte_code_cache
class TestByteCodeCache(object):

    def test_simple(self, env):
        tmpl = env.get_template('test.html')
        assert tmpl.render().strip() == 'BAR'
        pytest.raises(TemplateNotFound, env.get_template, 'missing.html')