test_helpers.py 文件源码

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

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

        @render.register_template(Foo)
        def get_context(x, request, **kwargs):
            return {'x': x, 'request': None}

        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 kwargs['context'] == {'x': foo, 'request': None}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号