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()
test_django_fakery_factories.py 文件源码
python
阅读 16
收藏 0
点赞 0
评论 0
评论列表
文章目录