conftest.py
This file
Path
tests/conftest.py
49 lines · 1.2 KiB · Python
Last changed by
Merge branch '3.0.x'David Lordbefore adoptioncdbda09
History of this fileTake it
1from pathlib import Path23import pytest45from jinja2 import loaders6from jinja2.environment import Environment789@pytest.fixture10def env():11 """returns a new environment."""12 return Environment()131415@pytest.fixture16def dict_loader():17 """returns DictLoader"""18 return loaders.DictLoader({"justdict.html": "FOO"})192021@pytest.fixture22def package_loader():23 """returns PackageLoader initialized from templates"""24 return loaders.PackageLoader("res", "templates")252627@pytest.fixture28def filesystem_loader():29 """returns FileSystemLoader initialized to res/templates directory"""30 here = Path(__file__).parent.resolve()31 return loaders.FileSystemLoader(here / "res" / "templates")323334@pytest.fixture35def function_loader():36 """returns a FunctionLoader"""37 return loaders.FunctionLoader({"justfunction.html": "FOO"}.get)383940@pytest.fixture41def choice_loader(dict_loader, package_loader):42 """returns a ChoiceLoader"""43 return loaders.ChoiceLoader([dict_loader, package_loader])444546@pytest.fixture47def prefix_loader(filesystem_loader, dict_loader):48 """returns a PrefixLoader"""49 return loaders.PrefixLoader({"a": filesystem_loader, "b": dict_loader})