Ticket #17046: patch_for_17046_another.diff

File patch_for_17046_another.diff, 2.0 KB (added by kwadrat, 13 years ago)
  • django/contrib/auth/models.py

    diff --git a/django/contrib/auth/models.py b/django/contrib/auth/models.py
    index 8064a4e..ce2a6af 100644
    a b class UserManager(models.Manager):  
    121121        Creates and saves a User with the given username, email and password.
    122122        """
    123123        now = timezone.now()
     124        if not username:
     125            raise ValueError('Username cannot be an empty string.')
    124126
    125127        # Normalize the address by lowercasing the domain part of the email
    126128        # address.
  • django/contrib/auth/tests/__init__.py

    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,  
    1010from django.contrib.auth.tests.remote_user import (RemoteUserTest,
    1111    RemoteUserNoCreateTest, RemoteUserCustomTest)
    1212from django.contrib.auth.tests.management import GetDefaultUsernameTestCase
    13 from django.contrib.auth.tests.models import ProfileTestCase
     13from django.contrib.auth.tests.models import (ProfileTestCase,
     14    UserEmptyUsernameCase)
    1415from django.contrib.auth.tests.hashers import TestUtilsHashPass
    1516from django.contrib.auth.tests.signals import SignalTestCase
    1617from django.contrib.auth.tests.tokens import TokenGeneratorTest
  • django/contrib/auth/tests/models.py

    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):  
    3333        # module that doesn't exist
    3434        settings.AUTH_PROFILE_MODULE = 'foo.bar'
    3535        self.assertRaises(SiteProfileNotAvailable, user.get_profile)
     36
     37
     38class 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='')
Back to Top