本文整理汇总了Python中affiliates.users.tests.UserFactory.build方法的典型用法代码示例。如果您正苦于以下问题:Python UserFactory.build方法的具体用法?Python UserFactory.build怎么用?Python UserFactory.build使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类affiliates.users.tests.UserFactory
的用法示例。
在下文中一共展示了UserFactory.build方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_create_profile
# 需要导入模块: from affiliates.users.tests import UserFactory [as 别名]
# 或者: from affiliates.users.tests.UserFactory import build [as 别名]
def test_create_profile(self):
"""Create an empty profile for newly-created users."""
user = UserFactory.build()
# Profile doesn't exist yet.
with self.assertRaises(UserProfile.DoesNotExist):
user.userprofile
# After saving, empty profile should exist.
user.save()
profile_pk = user.userprofile.pk
ok_(profile_pk is not None)
# If we save again, profile should not have been replaced.
user.userprofile.display_name = 'Bob'
user.userprofile.save()
user = User.objects.get(pk=user.pk)
eq_(user.userprofile.pk, profile_pk)