diff --git a/django/contrib/auth/models.py b/django/contrib/auth/models.py
index 8064a4e..ce2a6af 100644
a
|
b
|
class UserManager(models.Manager):
|
121 | 121 | Creates and saves a User with the given username, email and password. |
122 | 122 | """ |
123 | 123 | now = timezone.now() |
| 124 | if not username: |
| 125 | raise ValueError('Username cannot be an empty string.') |
124 | 126 | |
125 | 127 | # Normalize the address by lowercasing the domain part of the email |
126 | 128 | # address. |
diff --git a/django/contrib/auth/tests/__init__.py b/django/contrib/auth/tests/__init__.py
index 883e4c9..719d3e5 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, |
| 14 | UserEmptyUsernameCase) |
14 | 15 | from django.contrib.auth.tests.hashers import TestUtilsHashPass |
15 | 16 | from django.contrib.auth.tests.signals import SignalTestCase |
16 | 17 | from django.contrib.auth.tests.tokens import TokenGeneratorTest |
diff --git a/django/contrib/auth/tests/models.py b/django/contrib/auth/tests/models.py
index 754c6db..079b655 100644
a
|
b
|
class ProfileTestCase(TestCase):
|
33 | 33 | # module that doesn't exist |
34 | 34 | settings.AUTH_PROFILE_MODULE = 'foo.bar' |
35 | 35 | self.assertRaises(SiteProfileNotAvailable, user.get_profile) |
| 36 | |
| 37 | |
| 38 | class UserEmptyUsernameCase(TestCase): |
| 39 | def test_empty_username(self): |
| 40 | self.assertRaisesMessage(ValueError, |
| 41 | 'Username cannot be an empty string.', |
| 42 | User.objects.create_user, username='') |