Browse Source

Moved contrib.auth tests out of contrib.

Tim Graham 10 years ago
parent
commit
2d7aca3da0
44 changed files with 32 additions and 96 deletions
  1. 0 2
      MANIFEST.in
  2. 0 1
      django/contrib/auth/tests/__init__.py
  3. 1 0
      tests/auth_tests/__init__.py
  4. 1 1
      tests/auth_tests/backend_alias.py
  5. 0 0
      tests/auth_tests/fixtures/authtestdata.json
  6. 0 0
      tests/auth_tests/fixtures/context-processors-users.xml
  7. 0 0
      tests/auth_tests/fixtures/custom_user.json
  8. 0 0
      tests/auth_tests/fixtures/natural.json
  9. 0 0
      tests/auth_tests/fixtures/regular.json
  10. 0 0
      tests/auth_tests/settings.py
  11. 0 0
      tests/auth_tests/templates/context_processors/auth_attrs_access.html
  12. 0 0
      tests/auth_tests/templates/context_processors/auth_attrs_messages.html
  13. 0 0
      tests/auth_tests/templates/context_processors/auth_attrs_no_access.html
  14. 0 0
      tests/auth_tests/templates/context_processors/auth_attrs_perm_in_perms.html
  15. 0 0
      tests/auth_tests/templates/context_processors/auth_attrs_perms.html
  16. 0 0
      tests/auth_tests/templates/context_processors/auth_attrs_test_access.html
  17. 0 0
      tests/auth_tests/templates/context_processors/auth_attrs_user.html
  18. 0 0
      tests/auth_tests/templates/registration/html_password_reset_email.html
  19. 0 0
      tests/auth_tests/templates/registration/logged_out.html
  20. 0 0
      tests/auth_tests/templates/registration/login.html
  21. 0 0
      tests/auth_tests/templates/registration/password_change_form.html
  22. 0 0
      tests/auth_tests/templates/registration/password_reset_complete.html
  23. 0 0
      tests/auth_tests/templates/registration/password_reset_confirm.html
  24. 0 0
      tests/auth_tests/templates/registration/password_reset_done.html
  25. 0 0
      tests/auth_tests/templates/registration/password_reset_email.html
  26. 0 0
      tests/auth_tests/templates/registration/password_reset_form.html
  27. 0 0
      tests/auth_tests/templates/registration/password_reset_subject.txt
  28. 8 17
      tests/auth_tests/test_auth_backends.py
  29. 0 3
      tests/auth_tests/test_basic.py
  30. 1 3
      tests/auth_tests/test_context_processors.py
  31. 3 4
      tests/auth_tests/test_decorators.py
  32. 0 7
      tests/auth_tests/test_forms.py
  33. 0 3
      tests/auth_tests/test_handlers.py
  34. 2 2
      tests/auth_tests/test_hashers.py
  35. 4 16
      tests/auth_tests/test_management.py
  36. 0 0
      tests/auth_tests/test_middleware.py
  37. 2 7
      tests/auth_tests/test_models.py
  38. 4 9
      tests/auth_tests/test_remote_user.py
  39. 1 3
      tests/auth_tests/test_signals.py
  40. 1 3
      tests/auth_tests/test_templates.py
  41. 0 2
      tests/auth_tests/test_tokens.py
  42. 4 13
      tests/auth_tests/test_views.py
  43. 0 0
      tests/auth_tests/urls.py
  44. 0 0
      tests/auth_tests/urls_admin.py

+ 0 - 2
MANIFEST.in

@@ -18,9 +18,7 @@ recursive-include django/contrib/*/locale *
 recursive-include django/contrib/admin/templates *
 recursive-include django/contrib/admin/static *
 recursive-include django/contrib/admindocs/templates *
-recursive-include django/contrib/auth/fixtures *
 recursive-include django/contrib/auth/templates *
-recursive-include django/contrib/auth/tests/templates *
 recursive-include django/contrib/gis/gdal/tests/data *
 recursive-include django/contrib/gis/static *
 recursive-include django/contrib/gis/templates *

+ 0 - 1
django/contrib/auth/tests/__init__.py

@@ -1 +0,0 @@
-# The password for the fixture data users is 'password'

+ 1 - 0
tests/auth_tests/__init__.py

@@ -0,0 +1 @@
+# The password for the fixture data users is 'password'

+ 1 - 1
django/contrib/auth/tests/backend_alias.py → tests/auth_tests/backend_alias.py

@@ -1,4 +1,4 @@
 # For testing that auth backends can be referenced using a convenience import
-from django.contrib.auth.tests.test_auth_backends import ImportedModelBackend
+from .test_auth_backends import ImportedModelBackend
 
 __all__ = ['ImportedModelBackend']

+ 0 - 0
django/contrib/auth/fixtures/authtestdata.json → tests/auth_tests/fixtures/authtestdata.json


+ 0 - 0
django/contrib/auth/fixtures/context-processors-users.xml → tests/auth_tests/fixtures/context-processors-users.xml


+ 0 - 0
django/contrib/auth/fixtures/custom_user.json → tests/auth_tests/fixtures/custom_user.json


+ 0 - 0
django/contrib/auth/fixtures/natural.json → tests/auth_tests/fixtures/natural.json


+ 0 - 0
django/contrib/auth/fixtures/regular.json → tests/auth_tests/fixtures/regular.json


+ 0 - 0
django/contrib/auth/tests/settings.py → tests/auth_tests/settings.py


+ 0 - 0
django/contrib/auth/tests/templates/context_processors/auth_attrs_access.html → tests/auth_tests/templates/context_processors/auth_attrs_access.html


+ 0 - 0
django/contrib/auth/tests/templates/context_processors/auth_attrs_messages.html → tests/auth_tests/templates/context_processors/auth_attrs_messages.html


+ 0 - 0
django/contrib/auth/tests/templates/context_processors/auth_attrs_no_access.html → tests/auth_tests/templates/context_processors/auth_attrs_no_access.html


+ 0 - 0
django/contrib/auth/tests/templates/context_processors/auth_attrs_perm_in_perms.html → tests/auth_tests/templates/context_processors/auth_attrs_perm_in_perms.html


+ 0 - 0
django/contrib/auth/tests/templates/context_processors/auth_attrs_perms.html → tests/auth_tests/templates/context_processors/auth_attrs_perms.html


+ 0 - 0
django/contrib/auth/tests/templates/context_processors/auth_attrs_test_access.html → tests/auth_tests/templates/context_processors/auth_attrs_test_access.html


+ 0 - 0
django/contrib/auth/tests/templates/context_processors/auth_attrs_user.html → tests/auth_tests/templates/context_processors/auth_attrs_user.html


+ 0 - 0
django/contrib/auth/tests/templates/registration/html_password_reset_email.html → tests/auth_tests/templates/registration/html_password_reset_email.html


+ 0 - 0
django/contrib/auth/tests/templates/registration/logged_out.html → tests/auth_tests/templates/registration/logged_out.html


+ 0 - 0
django/contrib/auth/tests/templates/registration/login.html → tests/auth_tests/templates/registration/login.html


+ 0 - 0
django/contrib/auth/tests/templates/registration/password_change_form.html → tests/auth_tests/templates/registration/password_change_form.html


+ 0 - 0
django/contrib/auth/tests/templates/registration/password_reset_complete.html → tests/auth_tests/templates/registration/password_reset_complete.html


+ 0 - 0
django/contrib/auth/tests/templates/registration/password_reset_confirm.html → tests/auth_tests/templates/registration/password_reset_confirm.html


+ 0 - 0
django/contrib/auth/tests/templates/registration/password_reset_done.html → tests/auth_tests/templates/registration/password_reset_done.html


+ 0 - 0
django/contrib/auth/tests/templates/registration/password_reset_email.html → tests/auth_tests/templates/registration/password_reset_email.html


+ 0 - 0
django/contrib/auth/tests/templates/registration/password_reset_form.html → tests/auth_tests/templates/registration/password_reset_form.html


+ 0 - 0
django/contrib/auth/tests/templates/registration/password_reset_subject.txt → tests/auth_tests/templates/registration/password_reset_subject.txt


+ 8 - 17
django/contrib/auth/tests/test_auth_backends.py → tests/auth_tests/test_auth_backends.py

@@ -9,7 +9,6 @@ from django.contrib.auth.models import AnonymousUser, Group, Permission, User
 from django.contrib.auth.tests.custom_user import (
     CustomPermissionsUser, CustomUser, ExtensionUser,
 )
-from django.contrib.auth.tests.utils import skipIfCustomUser
 from django.contrib.contenttypes.models import ContentType
 from django.core.exceptions import ImproperlyConfigured, PermissionDenied
 from django.http import HttpRequest
@@ -176,7 +175,7 @@ class BaseModelBackendTest(object):
         user = self.UserModel._default_manager.get(pk=self.superuser.pk)
         self.assertEqual(len(user.get_all_permissions()), len(Permission.objects.all()))
 
-    @override_settings(PASSWORD_HASHERS=['django.contrib.auth.tests.test_auth_backends.CountingMD5PasswordHasher'])
+    @override_settings(PASSWORD_HASHERS=['auth_tests.test_auth_backends.CountingMD5PasswordHasher'])
     def test_authentication_timing(self):
         """Hasher is run once regardless of whether the user exists. Refs #20760."""
         # Re-set the password, because this tests overrides PASSWORD_HASHERS
@@ -193,7 +192,6 @@ class BaseModelBackendTest(object):
         self.assertEqual(CountingMD5PasswordHasher.calls, 1)
 
 
-@skipIfCustomUser
 class ModelBackendTest(BaseModelBackendTest, TestCase):
     """
     Tests for the ModelBackend using the default User model.
@@ -340,9 +338,8 @@ class SimpleRowlevelBackend(object):
             return ['none']
 
 
-@skipIfCustomUser
 @modify_settings(AUTHENTICATION_BACKENDS={
-    'append': 'django.contrib.auth.tests.test_auth_backends.SimpleRowlevelBackend',
+    'append': 'auth_tests.test_auth_backends.SimpleRowlevelBackend',
 })
 class RowlevelBackendTest(TestCase):
     """
@@ -381,7 +378,7 @@ class RowlevelBackendTest(TestCase):
 
 
 @override_settings(
-    AUTHENTICATION_BACKENDS=['django.contrib.auth.tests.test_auth_backends.SimpleRowlevelBackend'],
+    AUTHENTICATION_BACKENDS=['auth_tests.test_auth_backends.SimpleRowlevelBackend'],
 )
 class AnonymousUserBackendTest(TestCase):
     """
@@ -407,7 +404,6 @@ class AnonymousUserBackendTest(TestCase):
         self.assertEqual(self.user1.get_all_permissions(TestObj()), {'anon'})
 
 
-@skipIfCustomUser
 @override_settings(AUTHENTICATION_BACKENDS=[])
 class NoBackendsTest(TestCase):
     """
@@ -420,8 +416,7 @@ class NoBackendsTest(TestCase):
         self.assertRaises(ImproperlyConfigured, self.user.has_perm, ('perm', TestObj(),))
 
 
-@skipIfCustomUser
-@override_settings(AUTHENTICATION_BACKENDS=['django.contrib.auth.tests.test_auth_backends.SimpleRowlevelBackend'])
+@override_settings(AUTHENTICATION_BACKENDS=['auth_tests.test_auth_backends.SimpleRowlevelBackend'])
 class InActiveUserBackendTest(TestCase):
     """
     Tests for an inactive user
@@ -459,12 +454,11 @@ class PermissionDeniedBackend(object):
         raise PermissionDenied
 
 
-@skipIfCustomUser
 class PermissionDeniedBackendTest(TestCase):
     """
     Tests that other backends are not checked once a backend raises PermissionDenied
     """
-    backend = 'django.contrib.auth.tests.test_auth_backends.PermissionDeniedBackend'
+    backend = 'auth_tests.test_auth_backends.PermissionDeniedBackend'
 
     def setUp(self):
         self.user1 = User.objects.create_user('test', 'test@example.com', 'test')
@@ -502,12 +496,11 @@ class NewModelBackend(ModelBackend):
     pass
 
 
-@skipIfCustomUser
 class ChangedBackendSettingsTest(TestCase):
     """
     Tests for changes in the settings.AUTHENTICATION_BACKENDS
     """
-    backend = 'django.contrib.auth.tests.test_auth_backends.NewModelBackend'
+    backend = 'auth_tests.test_auth_backends.NewModelBackend'
 
     TEST_USERNAME = 'test_user'
     TEST_PASSWORD = 'test_password'
@@ -559,14 +552,13 @@ class TypeErrorBackend(object):
         raise TypeError
 
 
-@skipIfCustomUser
 class TypeErrorBackendTest(TestCase):
     """
     Tests that a TypeError within a backend is propagated properly.
 
     Regression test for ticket #18171
     """
-    backend = 'django.contrib.auth.tests.test_auth_backends.TypeErrorBackend'
+    backend = 'auth_tests.test_auth_backends.TypeErrorBackend'
 
     def setUp(self):
         self.user1 = User.objects.create_user('test', 'test@example.com', 'test')
@@ -576,7 +568,6 @@ class TypeErrorBackendTest(TestCase):
         self.assertRaises(TypeError, authenticate, username='test', password='test')
 
 
-@skipIfCustomUser
 class ImproperlyConfiguredUserModelTest(TestCase):
     """
     Tests that an exception from within get_user_model is propagated and doesn't
@@ -610,7 +601,7 @@ class ImportedBackendTests(TestCase):
     as the one defined in AUTHENTICATION_BACKENDS setting.
     """
 
-    backend = 'django.contrib.auth.tests.backend_alias.ImportedModelBackend'
+    backend = 'auth_tests.backend_alias.ImportedModelBackend'
 
     @override_settings(AUTHENTICATION_BACKENDS=[backend])
     def test_backend_path(self):

+ 0 - 3
django/contrib/auth/tests/test_basic.py → tests/auth_tests/test_basic.py

@@ -4,7 +4,6 @@ from django.apps import apps
 from django.contrib.auth import get_user_model
 from django.contrib.auth.models import AnonymousUser, User
 from django.contrib.auth.tests.custom_user import CustomUser
-from django.contrib.auth.tests.utils import skipIfCustomUser
 from django.core.exceptions import ImproperlyConfigured
 from django.dispatch import receiver
 from django.test import TestCase, override_settings
@@ -22,7 +21,6 @@ def user_model_swapped(**kwargs):
         apps.clear_cache()
 
 
-@skipIfCustomUser
 class BasicTestCase(TestCase):
     def test_user(self):
         "Check that users can be created and can set their password"
@@ -108,7 +106,6 @@ class BasicTestCase(TestCase):
         with self.assertRaises(ImproperlyConfigured):
             get_user_model()
 
-    @skipIfCustomUser
     def test_user_verbose_names_translatable(self):
         "Default User model verbose names are translatable (#19945)"
         with translation.override('en'):

+ 1 - 3
django/contrib/auth/tests/test_context_processors.py → tests/auth_tests/test_context_processors.py

@@ -6,7 +6,6 @@ from django.db.models import Q
 from django.test import TestCase, override_settings
 
 from .settings import AUTH_MIDDLEWARE_CLASSES, AUTH_TEMPLATES
-from .utils import skipIfCustomUser
 
 
 class MockUser(object):
@@ -58,10 +57,9 @@ class PermWrapperTests(TestCase):
             self.EQLimiterObject() in pldict
 
 
-@skipIfCustomUser
 @override_settings(
     PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'],
-    ROOT_URLCONF='django.contrib.auth.tests.urls',
+    ROOT_URLCONF='auth_tests.urls',
     TEMPLATES=AUTH_TEMPLATES,
     USE_TZ=False,                           # required for loading the fixture
 )

+ 3 - 4
django/contrib/auth/tests/test_decorators.py → tests/auth_tests/test_decorators.py

@@ -1,16 +1,15 @@
 from django.conf import settings
 from django.contrib.auth import models
 from django.contrib.auth.decorators import login_required, permission_required
-from django.contrib.auth.tests.test_views import AuthViewsTestCase
-from django.contrib.auth.tests.utils import skipIfCustomUser
 from django.core.exceptions import PermissionDenied
 from django.http import HttpResponse
 from django.test import TestCase, override_settings
 from django.test.client import RequestFactory
 
+from .test_views import AuthViewsTestCase
 
-@skipIfCustomUser
-@override_settings(ROOT_URLCONF='django.contrib.auth.tests.urls')
+
+@override_settings(ROOT_URLCONF='auth_tests.urls')
 class LoginRequiredTestCase(AuthViewsTestCase):
     """
     Tests the login_required decorators

+ 0 - 7
django/contrib/auth/tests/test_forms.py → tests/auth_tests/test_forms.py

@@ -19,10 +19,8 @@ from django.utils.text import capfirst
 from django.utils.translation import ugettext as _
 
 from .settings import AUTH_TEMPLATES
-from .utils import skipIfCustomUser
 
 
-@skipIfCustomUser
 @override_settings(USE_TZ=False, PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'])
 class UserCreationFormTest(TestCase):
 
@@ -90,7 +88,6 @@ class UserCreationFormTest(TestCase):
         self.assertEqual(repr(u), '<User: jsmith@example.com>')
 
 
-@skipIfCustomUser
 @override_settings(USE_TZ=False, PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'])
 class AuthenticationFormTest(TestCase):
 
@@ -203,7 +200,6 @@ class AuthenticationFormTest(TestCase):
         self.assertEqual(form.fields['username'].label, "")
 
 
-@skipIfCustomUser
 @override_settings(USE_TZ=False, PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'])
 class SetPasswordFormTest(TestCase):
 
@@ -231,7 +227,6 @@ class SetPasswordFormTest(TestCase):
         self.assertTrue(form.is_valid())
 
 
-@skipIfCustomUser
 @override_settings(USE_TZ=False, PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'])
 class PasswordChangeFormTest(TestCase):
 
@@ -280,7 +275,6 @@ class PasswordChangeFormTest(TestCase):
                          ['old_password', 'new_password1', 'new_password2'])
 
 
-@skipIfCustomUser
 @override_settings(USE_TZ=False, PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'])
 class UserChangeFormTest(TestCase):
 
@@ -359,7 +353,6 @@ class UserChangeFormTest(TestCase):
         self.assertEqual(form.initial['password'], form['password'].value())
 
 
-@skipIfCustomUser
 @override_settings(
     PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'],
     TEMPLATES=AUTH_TEMPLATES,

+ 0 - 3
django/contrib/auth/tests/test_handlers.py → tests/auth_tests/test_handlers.py

@@ -5,7 +5,6 @@ from django.contrib.auth.handlers.modwsgi import (
 )
 from django.contrib.auth.models import Group, User
 from django.contrib.auth.tests.custom_user import CustomUser
-from django.contrib.auth.tests.utils import skipIfCustomUser
 from django.test import TransactionTestCase, override_settings
 
 
@@ -21,7 +20,6 @@ class ModWsgiHandlerTestCase(TransactionTestCase):
         'django.contrib.contenttypes',
     ]
 
-    @skipIfCustomUser
     def test_check_password(self):
         """
         Verify that check_password returns the correct values as per
@@ -62,7 +60,6 @@ class ModWsgiHandlerTestCase(TransactionTestCase):
         # Valid user with incorrect password
         self.assertFalse(check_password({}, 'test@example.com', 'incorrect'))
 
-    @skipIfCustomUser
     def test_groups_for_user(self):
         """
         Check that groups_for_user returns correct values as per

+ 2 - 2
django/contrib/auth/tests/test_hashers.py → tests/auth_tests/test_hashers.py

@@ -295,7 +295,7 @@ class TestUtilsHashPass(SimpleTestCase):
             state['upgraded'] = True
 
         with self.settings(PASSWORD_HASHERS=[
-                'django.contrib.auth.tests.test_hashers.PBKDF2SingleIterationHasher']):
+                'auth_tests.test_hashers.PBKDF2SingleIterationHasher']):
             encoded = make_password('letmein')
             algo, iterations, salt, hash = encoded.split('$', 3)
             self.assertEqual(iterations, '1')
@@ -308,7 +308,7 @@ class TestUtilsHashPass(SimpleTestCase):
         # updated to the new iteration count.
         with self.settings(PASSWORD_HASHERS=[
                 'django.contrib.auth.hashers.PBKDF2PasswordHasher',
-                'django.contrib.auth.tests.test_hashers.PBKDF2SingleIterationHasher']):
+                'auth_tests.test_hashers.PBKDF2SingleIterationHasher']):
             self.assertTrue(check_password('letmein', encoded, setter))
             self.assertTrue(state['upgraded'])
 

+ 4 - 16
django/contrib/auth/tests/test_management.py → tests/auth_tests/test_management.py

@@ -13,9 +13,9 @@ from django.contrib.auth.management.commands import (
 )
 from django.contrib.auth.models import Group, User
 from django.contrib.auth.tests.custom_user import (
-    CustomUser, CustomUserWithFK, Email,
+    CustomUser, CustomUserBadRequiredFields, CustomUserNonListRequiredFields,
+    CustomUserNonUniqueUsername, CustomUserWithFK, Email,
 )
-from django.contrib.auth.tests.utils import skipIfCustomUser
 from django.contrib.contenttypes.models import ContentType
 from django.core import checks, exceptions
 from django.core.management import call_command
@@ -23,6 +23,7 @@ from django.core.management.base import CommandError
 from django.test import TestCase, override_settings, override_system_checks
 from django.utils import six
 from django.utils.encoding import force_str
+from django.utils.translation import ugettext_lazy as _
 
 
 def mock_inputs(inputs):
@@ -74,7 +75,6 @@ class MockTTY(object):
         return True
 
 
-@skipIfCustomUser
 class GetDefaultUsernameTestCase(TestCase):
 
     def setUp(self):
@@ -103,7 +103,6 @@ class GetDefaultUsernameTestCase(TestCase):
         self.assertEqual(management.get_default_username(), 'julia')
 
 
-@skipIfCustomUser
 class ChangepasswordManagementCommandTestCase(TestCase):
 
     def setUp(self):
@@ -155,7 +154,6 @@ class ChangepasswordManagementCommandTestCase(TestCase):
         command.execute(username="J\xfalia", stdout=self.stdout)
 
 
-@skipIfCustomUser
 @override_settings(SILENCED_SYSTEM_CHECKS=['fields.W342'])  # ForeignKey(unique=True)
 class CreatesuperuserManagementCommandTestCase(TestCase):
 
@@ -216,11 +214,9 @@ class CreatesuperuserManagementCommandTestCase(TestCase):
         'u\u017eivatel': 'foo',  # username (cz)
         'email': 'nolocale@somewhere.org'})
     def test_non_ascii_verbose_name(self):
-        # Aliased so the string doesn't get extracted
-        from django.utils.translation import ugettext_lazy as ulazy
         username_field = User._meta.get_field('username')
         old_verbose_name = username_field.verbose_name
-        username_field.verbose_name = ulazy('u\u017eivatel')
+        username_field.verbose_name = _('u\u017eivatel')
         new_io = six.StringIO()
         try:
             call_command(
@@ -422,8 +418,6 @@ class CustomUserModelValidationTestCase(TestCase):
     @override_system_checks([check_user_model])
     def test_required_fields_is_list(self):
         "REQUIRED_FIELDS should be a list."
-
-        from .custom_user import CustomUserNonListRequiredFields
         errors = checks.run_checks()
         expected = [
             checks.Error(
@@ -439,8 +433,6 @@ class CustomUserModelValidationTestCase(TestCase):
     @override_system_checks([check_user_model])
     def test_username_not_in_required_fields(self):
         "USERNAME_FIELD should not appear in REQUIRED_FIELDS."
-
-        from .custom_user import CustomUserBadRequiredFields
         errors = checks.run_checks()
         expected = [
             checks.Error(
@@ -457,8 +449,6 @@ class CustomUserModelValidationTestCase(TestCase):
     @override_system_checks([check_user_model])
     def test_username_non_unique(self):
         "A non-unique USERNAME_FIELD should raise a model validation error."
-
-        from .custom_user import CustomUserNonUniqueUsername
         errors = checks.run_checks()
         expected = [
             checks.Error(
@@ -480,8 +470,6 @@ class CustomUserModelValidationTestCase(TestCase):
         """ A non-unique USERNAME_FIELD should raise an error only if we use the
         default authentication backend. Otherwise, an warning should be raised.
         """
-
-        from .custom_user import CustomUserNonUniqueUsername
         errors = checks.run_checks()
         expected = [
             checks.Warning(

+ 0 - 0
django/contrib/auth/tests/test_middleware.py → tests/auth_tests/test_middleware.py


+ 2 - 7
django/contrib/auth/tests/test_models.py → tests/auth_tests/test_models.py

@@ -2,14 +2,14 @@ from django.contrib.auth import get_user_model
 from django.contrib.auth.models import (
     AbstractUser, Group, Permission, User, UserManager,
 )
-from django.contrib.auth.tests.utils import skipIfCustomUser
+# Needed so model is installed when tests are run independently:
+from django.contrib.auth.tests.custom_user import IsActiveTestUser1  # NOQA
 from django.contrib.contenttypes.models import ContentType
 from django.core import mail
 from django.db.models.signals import post_save
 from django.test import TestCase, override_settings
 
 
-@skipIfCustomUser
 @override_settings(USE_TZ=False)
 class NaturalKeysTestCase(TestCase):
     fixtures = ['authtestdata.json']
@@ -24,7 +24,6 @@ class NaturalKeysTestCase(TestCase):
         self.assertEqual(Group.objects.get_by_natural_key('users'), users_group)
 
 
-@skipIfCustomUser
 @override_settings(USE_TZ=False)
 class LoadDataWithoutNaturalKeysTestCase(TestCase):
     fixtures = ['regular.json']
@@ -35,7 +34,6 @@ class LoadDataWithoutNaturalKeysTestCase(TestCase):
         self.assertEqual(group, user.groups.get())
 
 
-@skipIfCustomUser
 @override_settings(USE_TZ=False)
 class LoadDataWithNaturalKeysTestCase(TestCase):
     fixtures = ['natural.json']
@@ -100,7 +98,6 @@ class LoadDataWithNaturalKeysAndMultipleDatabasesTestCase(TestCase):
         self.assertEqual(perm_other.content_type_id, other_objects[0].id)
 
 
-@skipIfCustomUser
 class UserManagerTestCase(TestCase):
 
     def test_create_user(self):
@@ -167,7 +164,6 @@ class IsActiveTestCase(TestCase):
     Tests the behavior of the guaranteed is_active attribute
     """
 
-    @skipIfCustomUser
     def test_builtin_user_isactive(self):
         user = User.objects.create(username='foo', email='foo@bar.com')
         # is_active is true by default
@@ -195,7 +191,6 @@ class IsActiveTestCase(TestCase):
         self.assertEqual(user_fetched.is_active, True)
 
 
-@skipIfCustomUser
 class TestCreateSuperUserSignals(TestCase):
     """
     Simple test case for ticket #20541

+ 4 - 9
django/contrib/auth/tests/test_remote_user.py → tests/auth_tests/test_remote_user.py

@@ -5,13 +5,11 @@ from django.contrib.auth import authenticate
 from django.contrib.auth.backends import RemoteUserBackend
 from django.contrib.auth.middleware import RemoteUserMiddleware
 from django.contrib.auth.models import User
-from django.contrib.auth.tests.utils import skipIfCustomUser
 from django.test import TestCase, modify_settings, override_settings
 from django.utils import timezone
 
 
-@skipIfCustomUser
-@override_settings(ROOT_URLCONF='django.contrib.auth.tests.urls')
+@override_settings(ROOT_URLCONF='auth_tests.urls')
 class RemoteUserTest(TestCase):
 
     middleware = 'django.contrib.auth.middleware.RemoteUserMiddleware'
@@ -153,14 +151,13 @@ class RemoteUserNoCreateBackend(RemoteUserBackend):
     create_unknown_user = False
 
 
-@skipIfCustomUser
 class RemoteUserNoCreateTest(RemoteUserTest):
     """
     Contains the same tests as RemoteUserTest, but using a custom auth backend
     class that doesn't create unknown users.
     """
 
-    backend = 'django.contrib.auth.tests.test_remote_user.RemoteUserNoCreateBackend'
+    backend = 'auth_tests.test_remote_user.RemoteUserNoCreateBackend'
 
     def test_unknown_user(self):
         num_users = User.objects.count()
@@ -189,14 +186,13 @@ class CustomRemoteUserBackend(RemoteUserBackend):
         return user
 
 
-@skipIfCustomUser
 class RemoteUserCustomTest(RemoteUserTest):
     """
     Tests a custom RemoteUserBackend subclass that overrides the clean_username
     and configure_user methods.
     """
 
-    backend = 'django.contrib.auth.tests.test_remote_user.CustomRemoteUserBackend'
+    backend = 'auth_tests.test_remote_user.CustomRemoteUserBackend'
     # REMOTE_USER strings with email addresses for the custom backend to
     # clean.
     known_user = 'knownuser@example.com'
@@ -227,13 +223,12 @@ class CustomHeaderMiddleware(RemoteUserMiddleware):
     header = 'HTTP_AUTHUSER'
 
 
-@skipIfCustomUser
 class CustomHeaderRemoteUserTest(RemoteUserTest):
     """
     Tests a custom RemoteUserMiddleware subclass with custom HTTP auth user
     header.
     """
     middleware = (
-        'django.contrib.auth.tests.test_remote_user.CustomHeaderMiddleware'
+        'auth_tests.test_remote_user.CustomHeaderMiddleware'
     )
     header = 'HTTP_AUTHUSER'

+ 1 - 3
django/contrib/auth/tests/test_signals.py → tests/auth_tests/test_signals.py

@@ -1,14 +1,12 @@
 from django.contrib.auth import signals
 from django.contrib.auth.models import User
-from django.contrib.auth.tests.utils import skipIfCustomUser
 from django.test import TestCase, override_settings
 from django.test.client import RequestFactory
 
 
-@skipIfCustomUser
 @override_settings(USE_TZ=False,
     PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'],
-    ROOT_URLCONF='django.contrib.auth.tests.urls')
+    ROOT_URLCONF='auth_tests.urls')
 class SignalTestCase(TestCase):
     fixtures = ['authtestdata.json']
 

+ 1 - 3
django/contrib/auth/tests/test_templates.py → tests/auth_tests/test_templates.py

@@ -1,6 +1,5 @@
 from django.contrib.auth import authenticate
 from django.contrib.auth.models import User
-from django.contrib.auth.tests.utils import skipIfCustomUser
 from django.contrib.auth.tokens import PasswordResetTokenGenerator
 from django.contrib.auth.views import (
     password_change, password_change_done, password_reset,
@@ -11,10 +10,9 @@ from django.utils.encoding import force_bytes, force_text
 from django.utils.http import urlsafe_base64_encode
 
 
-@skipIfCustomUser
 @override_settings(
     PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'],
-    ROOT_URLCONF='django.contrib.auth.tests.urls',
+    ROOT_URLCONF='auth_tests.urls',
 )
 class AuthTemplateTests(TestCase):
 

+ 0 - 2
django/contrib/auth/tests/test_tokens.py → tests/auth_tests/test_tokens.py

@@ -4,12 +4,10 @@ from datetime import date, timedelta
 
 from django.conf import settings
 from django.contrib.auth.models import User
-from django.contrib.auth.tests.utils import skipIfCustomUser
 from django.contrib.auth.tokens import PasswordResetTokenGenerator
 from django.test import TestCase
 
 
-@skipIfCustomUser
 class TokenGeneratorTest(TestCase):
 
     def test_make_token(self):

+ 4 - 13
django/contrib/auth/tests/test_views.py → tests/auth_tests/test_views.py

@@ -13,6 +13,8 @@ from django.contrib.auth.forms import (
     AuthenticationForm, PasswordChangeForm, SetPasswordForm,
 )
 from django.contrib.auth.models import User
+# Needed so model is installed when tests are run independently:
+from django.contrib.auth.tests.custom_user import CustomUser  # NOQA
 from django.contrib.auth.views import login as login_view, redirect_to_login
 from django.contrib.sessions.middleware import SessionMiddleware
 from django.contrib.sites.requests import RequestSite
@@ -30,10 +32,7 @@ from django.utils.http import urlquote
 from django.utils.six.moves.urllib.parse import ParseResult, urlparse
 from django.utils.translation import LANGUAGE_SESSION_KEY
 
-# Needed so model is installed when tests are run independently:
-from .custom_user import CustomUser  # NOQA
 from .settings import AUTH_TEMPLATES
-from .utils import skipIfCustomUser
 
 
 @override_settings(
@@ -44,7 +43,7 @@ from .utils import skipIfCustomUser
     TEMPLATES=AUTH_TEMPLATES,
     USE_TZ=False,
     PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'],
-    ROOT_URLCONF='django.contrib.auth.tests.urls',
+    ROOT_URLCONF='auth_tests.urls',
 )
 class AuthViewsTestCase(TestCase):
     """
@@ -88,7 +87,6 @@ class AuthViewsTestCase(TestCase):
                 self.fail("%r != %r (%s doesn't match)" % (url, expected, attr))
 
 
-@skipIfCustomUser
 @override_settings(ROOT_URLCONF='django.contrib.auth.urls')
 class AuthViewNamedURLTests(AuthViewsTestCase):
 
@@ -114,7 +112,6 @@ class AuthViewNamedURLTests(AuthViewsTestCase):
                 self.fail("Reversal of url named '%s' failed with NoReverseMatch" % name)
 
 
-@skipIfCustomUser
 class PasswordResetTest(AuthViewsTestCase):
 
     def test_email_not_found(self):
@@ -357,7 +354,6 @@ class CustomUserPasswordResetTest(AuthViewsTestCase):
         self.assertContains(response, "Please enter your new password")
 
 
-@skipIfCustomUser
 class ChangePasswordTest(AuthViewsTestCase):
 
     def fail_login(self, password='password'):
@@ -466,7 +462,6 @@ class SessionAuthenticationTests(AuthViewsTestCase):
         self.assertRedirects(response, '/password_change/done/')
 
 
-@skipIfCustomUser
 class LoginTest(AuthViewsTestCase):
 
     def test_current_site_in_context_after_login(self):
@@ -616,7 +611,6 @@ class LoginTest(AuthViewsTestCase):
         self.assertNotEqual(original_session_key, self.client.session.session_key)
 
 
-@skipIfCustomUser
 class LoginURLSettings(AuthViewsTestCase):
     """Tests for settings.LOGIN_URL."""
     def assertLoginURLEquals(self, url, parse_qs=False):
@@ -659,7 +653,6 @@ class LoginURLSettings(AuthViewsTestCase):
         self.assertLoginURLEquals('/login/?next=/login_required/')
 
 
-@skipIfCustomUser
 class LoginRedirectUrlTest(AuthViewsTestCase):
     """Tests for settings.LOGIN_REDIRECT_URL."""
     def assertLoginRedirectURLEqual(self, url):
@@ -698,7 +691,6 @@ class RedirectToLoginTests(AuthViewsTestCase):
         self.assertEqual(expected, login_redirect_response.url)
 
 
-@skipIfCustomUser
 class LogoutTest(AuthViewsTestCase):
 
     def confirm_logged_out(self):
@@ -820,13 +812,12 @@ class LogoutTest(AuthViewsTestCase):
 
 # Redirect in test_user_change_password will fail if session auth hash
 # isn't updated after password change (#21649)
-@skipIfCustomUser
 @modify_settings(MIDDLEWARE_CLASSES={
     'append': 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 })
 @override_settings(
     PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'],
-    ROOT_URLCONF='django.contrib.auth.tests.urls_admin',
+    ROOT_URLCONF='auth_tests.urls_admin',
 )
 class ChangelistTests(AuthViewsTestCase):
 

+ 0 - 0
django/contrib/auth/tests/urls.py → tests/auth_tests/urls.py


+ 0 - 0
django/contrib/auth/tests/urls_admin.py → tests/auth_tests/urls_admin.py