Update test_imports.py

Add regression test for macro include
This commit is contained in:
kljnepk 2026-04-13 23:54:34 +02:00 committed by GitHub
parent 301056e6c8
commit a35473d76b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -195,6 +195,18 @@ class TestIncludes:
)
assert t.render().strip() == "(FOO)"
def test_include_without_context_inside_macro(self, test_env):
test_env.loader.mapping["included"] = "foo"
t = test_env.from_string(
"""
{%- macro foo() %}
{%- include "included" without context %}
{%- endmacro %}
{{- foo() -}}
"""
)
assert t.render() == "foo"
def test_import_from_with_context(self):
env = Environment(
loader=DictLoader({"a": "{% macro x() %}{{ foobar }}{% endmacro %}"})