Skip to content
Myr

add more tests for import context behavior

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Amy · committed by Amy · parent 5eea6e4 · Browse files · 1 file+24 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+24 added−0 removed

  • tests:+24 added−0 removed

1 file+24 added−0 removed

modified:tests/test_imports.py+24 added
96 unmodified lines
9798 with pytest.raises(UndefinedError, match="does not export the requested name"):99 t.render()100101 def test_import_with_globals(self, test_env):102 env = Environment(103 loader=DictLoader(104 {105 "macros": "{% macro testing() %}foo: {{ foo }}{% endmacro %}",106 "test": "{% import 'macros' as m %}{{ m.testing() }}",107 }108 )109 )110 tmpl = env.get_template("test", globals={"foo": "bar"})111 assert tmpl.render() == "foo: bar"112113 def test_from_import_with_globals(self, test_env):114 env = Environment(115 loader=DictLoader(116 {117 "macros": "{% macro testing() %}foo: {{ foo }}{% endmacro %}",118 "test": "{% from 'macros' import testing %}{{ testing() }}",119 }120 )121 )122 tmpl = env.get_template("test", globals={"foo": "bar"})123 assert tmpl.render() == "foo: bar"124125126class TestIncludes:127 def test_context_include(self, test_env):128 t = test_env.from_string('{% include "header" %}')129 assert t.render(foo=42) == "[42|23]"
77 unmodified lines