Skip to content

jinja2 no longer supports the pytest loader #1168

@gaborbernat

Description

@gaborbernat

Currently, jinja2 expects either _path defined or get_filenames: https://github.com/pallets/jinja/blob/master/src/jinja2/loaders.py#L262-L281

The pytest assertion rewriter defines neither (see https://github.com/pytest-dev/pytest/blob/master/src/_pytest/assertion/rewrite.py#L48), and as such running a test suite on a source code that has the following global:

from jinja2 import PackageLoader
LOADER = PackageLoader(__name__, "templates")

will fail with:

    raise ValueError(
E   ValueError: The 'xxx' package was not installed in a way that PackageLoader understands.

Not sure if here jinja2 needs to support more ways to get the template rooot, or pytest loader is missing some methods.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions