Skip to content

Commit

Permalink
tests: speed up unit tests by caching the jinja bytecode between tests
Browse files Browse the repository at this point in the history
  • Loading branch information
azmeuk committed Apr 16, 2024
1 parent 1decf16 commit 1080952
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pytest
from babel.messages.frontend import compile_catalog
from flask_webtest import TestApp
from jinja2 import FileSystemBytecodeCache
from jinja2 import StrictUndefined
from pytest_lazyfixture import lazy_fixture
from werkzeug.security import gen_salt
Expand Down Expand Up @@ -151,9 +152,15 @@ def configuration(smtpd):
return conf


@pytest.fixture(scope="session")
def jinja_cache_directory(tmp_path_factory):
return tmp_path_factory.mktemp("cache")


@pytest.fixture
def app(configuration, backend):
def app(configuration, backend, jinja_cache_directory):
app = create_app(configuration, backend=backend)
app.jinja_env.bytecode_cache = FileSystemBytecodeCache(jinja_cache_directory)
backend.install(app.config)
with app.test_request_context():
yield app
Expand Down

0 comments on commit 1080952

Please sign in to comment.