tests.py 文件源码

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

项目:deb-python-django-formtools 作者: openstack 项目源码 文件源码
def test_get_context_data_inheritance(self):
        class TestWizard(CookieWizardView):
            """
            A subclass that implements ``get_context_data`` using the standard
            protocol for generic views (accept only **kwargs).

            See ticket #17148.
            """
            def get_context_data(self, **kwargs):
                context = super(TestWizard, self).get_context_data(**kwargs)
                context['test_key'] = 'test_value'
                return context

        factory = RequestFactory()
        view = TestWizard.as_view([forms.Form])

        response = view(factory.get('/'))
        self.assertEqual(response.context_data['test_key'], 'test_value')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号