diff options
Diffstat (limited to 'tests/test_imports.py')
-rw-r--r-- | tests/test_imports.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/test_imports.py b/tests/test_imports.py index 7a2bd942..bb7400f8 100644 --- a/tests/test_imports.py +++ b/tests/test_imports.py @@ -98,6 +98,30 @@ class TestImports: with pytest.raises(UndefinedError, match="does not export the requested name"): t.render() + def test_import_with_globals(self, test_env): + env = Environment( + loader=DictLoader( + { + "macros": "{% macro testing() %}foo: {{ foo }}{% endmacro %}", + "test": "{% import 'macros' as m %}{{ m.testing() }}", + } + ) + ) + tmpl = env.get_template("test", globals={"foo": "bar"}) + assert tmpl.render() == "foo: bar" + + def test_from_import_with_globals(self, test_env): + env = Environment( + loader=DictLoader( + { + "macros": "{% macro testing() %}foo: {{ foo }}{% endmacro %}", + "test": "{% from 'macros' import testing %}{{ testing() }}", + } + ) + ) + tmpl = env.get_template("test", globals={"foo": "bar"}) + assert tmpl.render() == "foo: bar" + class TestIncludes: def test_context_include(self, test_env): |