test_model_mommy_factories.py 文件源码

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

项目:factory_audit 作者: jamescooke 项目源码 文件源码
def test_default(self):
        """
        Model Mommy: Plant.Item: YELLOW (raises IntegrityError)

        There is no method used to create unique values so there are collisions
        when there are a small number of possible values. Items that are
        created are valid.
        """
        with self.assertRaises(IntegrityError) as cm:
            for expected_num_created in range(1, 25):
                with transaction.atomic():
                    ItemFactory()

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


问题


面经


文章

微信
公众号

扫码关注公众号