diff --git a/django/contrib/auth/models.py b/django/contrib/auth/models.py
index 04e68aa..4f25c42 100644
|
a
|
b
|
import urllib
|
| 3 | 3 | |
| 4 | 4 | from django.core.exceptions import ImproperlyConfigured |
| 5 | 5 | from django.core.mail import send_mail |
| 6 | | from django.db import models |
| | 6 | from django.db import models, IntegrityError |
| 7 | 7 | from django.db.models.manager import EmptyManager |
| 8 | 8 | from django.utils.encoding import smart_str |
| 9 | 9 | from django.utils.translation import ugettext_lazy as _ |
| … |
… |
class UserManager(models.Manager):
|
| 93 | 93 | """ |
| 94 | 94 | now = datetime.datetime.now() |
| 95 | 95 | |
| | 96 | if username == '': |
| | 97 | raise IntegrityError("Username can't be blank") |
| | 98 | |
| 96 | 99 | # Normalize the address by lowercasing the domain part of the email |
| 97 | 100 | # address. |
| 98 | 101 | email = email or '' |
diff --git a/django/contrib/auth/tests/__init__.py b/django/contrib/auth/tests/__init__.py
index 7cb0dcb..71d2bd4 100644
|
a
|
b
|
from django.contrib.auth.tests.forms import (UserCreationFormTest,
|
| 10 | 10 | from django.contrib.auth.tests.remote_user import (RemoteUserTest, |
| 11 | 11 | RemoteUserNoCreateTest, RemoteUserCustomTest) |
| 12 | 12 | from django.contrib.auth.tests.management import GetDefaultUsernameTestCase |
| 13 | | from django.contrib.auth.tests.models import ProfileTestCase |
| | 13 | from django.contrib.auth.tests.models import ProfileTestCase, UserEmptyUsernameCase |
| 14 | 14 | from django.contrib.auth.tests.signals import SignalTestCase |
| 15 | 15 | from django.contrib.auth.tests.tokens import TokenGeneratorTest |
| 16 | 16 | from django.contrib.auth.tests.views import (AuthViewNamedURLTests, PasswordResetTest, |
diff --git a/django/contrib/auth/tests/models.py b/django/contrib/auth/tests/models.py
index 754c6db..7ab947d 100644
|
a
|
b
|
|
| 1 | 1 | from django.conf import settings |
| 2 | 2 | from django.test import TestCase |
| 3 | 3 | from django.contrib.auth.models import User, SiteProfileNotAvailable |
| | 4 | from django.db import IntegrityError |
| 4 | 5 | |
| 5 | 6 | class ProfileTestCase(TestCase): |
| 6 | 7 | fixtures = ['authtestdata.json'] |
| … |
… |
class ProfileTestCase(TestCase):
|
| 33 | 34 | # module that doesn't exist |
| 34 | 35 | settings.AUTH_PROFILE_MODULE = 'foo.bar' |
| 35 | 36 | self.assertRaises(SiteProfileNotAvailable, user.get_profile) |
| | 37 | |
| | 38 | |
| | 39 | class UserEmptyUsernameCase(TestCase): |
| | 40 | |
| | 41 | def test_empty_username(self): |
| | 42 | with self.assertRaises(IntegrityError): |
| | 43 | User.objects.create_user(username='', password='passsword', |
| | 44 | email='email@email.com') |