本文整理匯總了Python中django_browserid.auth.BrowserIDBackend.User方法的典型用法代碼示例。如果您正苦於以下問題:Python BrowserIDBackend.User方法的具體用法?Python BrowserIDBackend.User怎麽用?Python BrowserIDBackend.User使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類django_browserid.auth.BrowserIDBackend
的用法示例。
在下文中一共展示了BrowserIDBackend.User方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_create_user_integrity_error
# 需要導入模塊: from django_browserid.auth import BrowserIDBackend [as 別名]
# 或者: from django_browserid.auth.BrowserIDBackend import User [as 別名]
def test_create_user_integrity_error(self, logger):
# If an IntegrityError is raised during user creation, attempt to re-fetch the user in case
# the user was created since we checked for the existing account.
backend = BrowserIDBackend()
backend.User = Mock()
error = IntegrityError()
backend.User.objects.create_user.side_effect = error
backend.User.objects.get.return_value = 'asdf'
self.assertEqual(backend.create_user('[email protected]'), 'asdf')
# If get raises a DoesNotExist exception, re-raise the original exception.
backend.User.DoesNotExist = Exception
backend.User.objects.get.side_effect = backend.User.DoesNotExist
with self.assertRaises(IntegrityError) as e:
backend.create_user('[email protected]')
self.assertEqual(e.exception, error)