test_functional.py 文件源码

python
阅读 39 收藏 0 点赞 0 评论 0

项目:Flask-Copilot 作者: jonafato 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号