conftest.py
This file
Path
tests/conftest.py
57 lines · 1.3 KiB · Python
Last changed by
remove custom pytest marksDavid Lordbefore adoptiondd5a050
History of this fileTake it
1# -*- coding: utf-8 -*-2import os34import pytest56from jinja2 import Environment7from jinja2 import loaders8from jinja2.utils import have_async_gen91011def pytest_ignore_collect(path):12 if "async" in path.basename and not have_async_gen:13 return True14 return False151617@pytest.fixture18def env():19 """returns a new environment."""20 return Environment()212223@pytest.fixture24def dict_loader():25 """returns DictLoader"""26 return loaders.DictLoader({"justdict.html": "FOO"})272829@pytest.fixture30def package_loader():31 """returns PackageLoader initialized from templates"""32 return loaders.PackageLoader("res", "templates")333435@pytest.fixture36def filesystem_loader():37 """returns FileSystemLoader initialized to res/templates directory"""38 here = os.path.dirname(os.path.abspath(__file__))39 return loaders.FileSystemLoader(here + "/res/templates")404142@pytest.fixture43def function_loader():44 """returns a FunctionLoader"""45 return loaders.FunctionLoader({"justfunction.html": "FOO"}.get)464748@pytest.fixture49def choice_loader(dict_loader, package_loader):50 """returns a ChoiceLoader"""51 return loaders.ChoiceLoader([dict_loader, package_loader])525354@pytest.fixture55def prefix_loader(filesystem_loader, dict_loader):56 """returns a PrefixLoader"""57 return loaders.PrefixLoader({"a": filesystem_loader, "b": dict_loader})