test_helpers.py 文件源码

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

项目:django-bricks 作者: fabiommendes 项目源码 文件源码
def test_register_template(self):
        class Foo:
            pass

        render.register_template(Foo)
        result = []

        def f(*args, **kwargs):
            result.append((args, kwargs))
            return ''

        with mock.patch('bricks.helpers.render._render_template', f):
            foo = Foo()
            x = render(foo)
            args, kwargs = result.pop()
            assert args == (['bricks/foo.html', 'bricks/foo.jinja2'],)
            assert sorted(kwargs) == ['context', 'request']
            request = kwargs['context']['request']
            assert hasattr(request, 'POST')
            assert kwargs['context'] == {'foo': foo, 'request': request}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号