def test_template_context(test_app, test_pilot):
"""Test that the template context gets injected properly."""
test_pilot.init_app(test_app)
@test_app.route('/', navbar_kwargs={'path': ('Home',)})
def index():
pass
template_string = '''
{% for entry in navbar %}
<a href="{{ entry.url() }}">{{ entry.name }}</a>
{% endfor %}
'''
with test_app.test_request_context('/'):
rendered = render_template_string(template_string)
expected = '<a href="/">Home</a>'
assert rendered.strip() == expected
评论列表
文章目录