tests.py 文件源码

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

项目:openbare 作者: openbare 项目源码 文件源码
def test_checkout_exception(self):
        self.c.login(username=self.user.username, password='str0ngpa$$w0rd')

        # Test check out lendable raises exception
        with patch.object(Lendable,
                          'checkout',
                          side_effect=Exception('Checkout Failed!')):
            response = self.c.get(reverse('library:checkout',
                                          args=['lendable']),
                                  follow=True)

        # Confirm error message displayed
        message = list(response.context['messages'])[0].message
        self.assertEqual(message, 'Checkout Failed!')

        # Confirm lendable not created
        self.assertEqual(Lendable.all_types.count(), 0)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号