test_django_fakery_factories.py 文件源码

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

项目:factory_audit 作者: jamescooke 项目源码 文件源码
def test_default(self):
        """
        Django Fakery: User Model: YELLOW (raises IntegrityError)

        We have to push the number of Users created, but since Django Fakery
        has no collision protection and uses a small number of latin words it
        will always fail sooner or later. Sometimes on the second user.

        However, instances created are valid if they are able to enter the
        database.
        """
        with self.assertRaises(IntegrityError) as cm:
            for expected_num_created in range(1, 100):
                with transaction.atomic():
                    UserFactory()

        self.assertEqual(self.user_model.objects.count(), expected_num_created - 1)
        self.assertIn('unique', str(cm.exception).lower())
        for u in self.user_model.objects.all():
            u.full_clean()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号