diff --git a/django/contrib/auth/tests/__init__.py b/django/contrib/auth/tests/__init__.py index 038c8980d9..2e35e33d7f 100644 --- a/django/contrib/auth/tests/__init__.py +++ b/django/contrib/auth/tests/__init__.py @@ -1,29 +1,16 @@ -from django.contrib.auth.tests.custom_user import * -from django.contrib.auth.tests.auth_backends import * -from django.contrib.auth.tests.basic import * -from django.contrib.auth.tests.context_processors import * -from django.contrib.auth.tests.decorators import * -from django.contrib.auth.tests.forms import * -from django.contrib.auth.tests.remote_user import * -from django.contrib.auth.tests.management import * -from django.contrib.auth.tests.models import * -from django.contrib.auth.tests.handlers import * -from django.contrib.auth.tests.hashers import * -from django.contrib.auth.tests.signals import * -from django.contrib.auth.tests.tokens import * -from django.contrib.auth.tests.views import * +from django.contrib.auth.tests.test_custom_user import * +from django.contrib.auth.tests.test_auth_backends import * +from django.contrib.auth.tests.test_basic import * +from django.contrib.auth.tests.test_context_processors import * +from django.contrib.auth.tests.test_decorators import * +from django.contrib.auth.tests.test_forms import * +from django.contrib.auth.tests.test_remote_user import * +from django.contrib.auth.tests.test_management import * +from django.contrib.auth.tests.test_models import * +from django.contrib.auth.tests.test_handlers import * +from django.contrib.auth.tests.test_hashers import * +from django.contrib.auth.tests.test_signals import * +from django.contrib.auth.tests.test_tokens import * +from django.contrib.auth.tests.test_views import * # The password for the fixture data users is 'password' - -from django.dispatch import receiver -from django.test.signals import setting_changed - - -@receiver(setting_changed) -def user_model_swapped(**kwargs): - if kwargs['setting'] == 'AUTH_USER_MODEL': - from django.db.models.manager import ensure_default_manager - from django.contrib.auth.models import User - # Reset User manager - setattr(User, 'objects', User._default_manager) - ensure_default_manager(User) diff --git a/django/contrib/auth/tests/auth_backends.py b/django/contrib/auth/tests/test_auth_backends.py similarity index 97% rename from django/contrib/auth/tests/auth_backends.py rename to django/contrib/auth/tests/test_auth_backends.py index 20bbb4dbd4..bb97c54a11 100644 --- a/django/contrib/auth/tests/auth_backends.py +++ b/django/contrib/auth/tests/test_auth_backends.py @@ -4,7 +4,7 @@ from datetime import date from django.conf import settings from django.contrib.auth.models import User, Group, Permission, AnonymousUser from django.contrib.auth.tests.utils import skipIfCustomUser -from django.contrib.auth.tests.custom_user import ExtensionUser, CustomPermissionsUser, CustomUser +from django.contrib.auth.tests.test_custom_user import ExtensionUser, CustomPermissionsUser, CustomUser from django.contrib.contenttypes.models import ContentType from django.core.exceptions import ImproperlyConfigured, PermissionDenied from django.contrib.auth import authenticate @@ -263,7 +263,7 @@ class RowlevelBackendTest(TestCase): """ Tests for auth backend that supports object level permissions """ - backend = 'django.contrib.auth.tests.auth_backends.SimpleRowlevelBackend' + backend = 'django.contrib.auth.tests.test_auth_backends.SimpleRowlevelBackend' def setUp(self): self.curr_auth = settings.AUTHENTICATION_BACKENDS @@ -304,7 +304,7 @@ class AnonymousUserBackendTest(TestCase): Tests for AnonymousUser delegating to backend. """ - backend = 'django.contrib.auth.tests.auth_backends.SimpleRowlevelBackend' + backend = 'django.contrib.auth.tests.test_auth_backends.SimpleRowlevelBackend' def setUp(self): self.curr_auth = settings.AUTHENTICATION_BACKENDS @@ -348,7 +348,7 @@ class InActiveUserBackendTest(TestCase): """ Tests for a inactive user """ - backend = 'django.contrib.auth.tests.auth_backends.SimpleRowlevelBackend' + backend = 'django.contrib.auth.tests.test_auth_backends.SimpleRowlevelBackend' def setUp(self): self.curr_auth = settings.AUTHENTICATION_BACKENDS @@ -386,7 +386,7 @@ class PermissionDeniedBackendTest(TestCase): """ Tests that other backends are not checked once a backend raises PermissionDenied """ - backend = 'django.contrib.auth.tests.auth_backends.PermissionDeniedBackend' + backend = 'django.contrib.auth.tests.test_auth_backends.PermissionDeniedBackend' def setUp(self): self.user1 = User.objects.create_user('test', 'test@example.com', 'test') diff --git a/django/contrib/auth/tests/basic.py b/django/contrib/auth/tests/test_basic.py similarity index 94% rename from django/contrib/auth/tests/basic.py rename to django/contrib/auth/tests/test_basic.py index ec94fe5b46..6b1dd3af05 100644 --- a/django/contrib/auth/tests/basic.py +++ b/django/contrib/auth/tests/test_basic.py @@ -6,17 +6,29 @@ import locale from django.contrib.auth import get_user_model from django.contrib.auth.management.commands import createsuperuser from django.contrib.auth.models import User, AnonymousUser -from django.contrib.auth.tests.custom_user import CustomUser +from django.contrib.auth.tests.test_custom_user import CustomUser from django.contrib.auth.tests.utils import skipIfCustomUser from django.core.exceptions import ImproperlyConfigured from django.core.management import call_command +from django.dispatch import receiver from django.test import TestCase +from django.test.signals import setting_changed from django.test.utils import override_settings from django.utils import translation from django.utils.encoding import force_str from django.utils.six import binary_type, PY3, StringIO +@receiver(setting_changed) +def user_model_swapped(**kwargs): + if kwargs['setting'] == 'AUTH_USER_MODEL': + from django.db.models.manager import ensure_default_manager + from django.contrib.auth.models import User + # Reset User manager + setattr(User, 'objects', User._default_manager) + ensure_default_manager(User) + + def mock_inputs(inputs): """ Decorator to temporarily replace input/getpass to allow interactive diff --git a/django/contrib/auth/tests/context_processors.py b/django/contrib/auth/tests/test_context_processors.py similarity index 100% rename from django/contrib/auth/tests/context_processors.py rename to django/contrib/auth/tests/test_context_processors.py diff --git a/django/contrib/auth/tests/custom_user.py b/django/contrib/auth/tests/test_custom_user.py similarity index 100% rename from django/contrib/auth/tests/custom_user.py rename to django/contrib/auth/tests/test_custom_user.py diff --git a/django/contrib/auth/tests/decorators.py b/django/contrib/auth/tests/test_decorators.py similarity index 95% rename from django/contrib/auth/tests/decorators.py rename to django/contrib/auth/tests/test_decorators.py index 5aff375498..a53dcd5bb7 100644 --- a/django/contrib/auth/tests/decorators.py +++ b/django/contrib/auth/tests/test_decorators.py @@ -1,5 +1,5 @@ from django.contrib.auth.decorators import login_required -from django.contrib.auth.tests.views import AuthViewsTestCase +from django.contrib.auth.tests.test_views import AuthViewsTestCase from django.contrib.auth.tests.utils import skipIfCustomUser diff --git a/django/contrib/auth/tests/forms.py b/django/contrib/auth/tests/test_forms.py similarity index 100% rename from django/contrib/auth/tests/forms.py rename to django/contrib/auth/tests/test_forms.py diff --git a/django/contrib/auth/tests/handlers.py b/django/contrib/auth/tests/test_handlers.py similarity index 100% rename from django/contrib/auth/tests/handlers.py rename to django/contrib/auth/tests/test_handlers.py diff --git a/django/contrib/auth/tests/hashers.py b/django/contrib/auth/tests/test_hashers.py similarity index 100% rename from django/contrib/auth/tests/hashers.py rename to django/contrib/auth/tests/test_hashers.py diff --git a/django/contrib/auth/tests/management.py b/django/contrib/auth/tests/test_management.py similarity index 100% rename from django/contrib/auth/tests/management.py rename to django/contrib/auth/tests/test_management.py diff --git a/django/contrib/auth/tests/models.py b/django/contrib/auth/tests/test_models.py similarity index 100% rename from django/contrib/auth/tests/models.py rename to django/contrib/auth/tests/test_models.py diff --git a/django/contrib/auth/tests/remote_user.py b/django/contrib/auth/tests/test_remote_user.py similarity index 98% rename from django/contrib/auth/tests/remote_user.py rename to django/contrib/auth/tests/test_remote_user.py index 0e59b291a8..dae61afed5 100644 --- a/django/contrib/auth/tests/remote_user.py +++ b/django/contrib/auth/tests/test_remote_user.py @@ -137,7 +137,7 @@ class RemoteUserNoCreateTest(RemoteUserTest): """ backend =\ - 'django.contrib.auth.tests.remote_user.RemoteUserNoCreateBackend' + 'django.contrib.auth.tests.test_remote_user.RemoteUserNoCreateBackend' def test_unknown_user(self): num_users = User.objects.count() @@ -174,7 +174,7 @@ class RemoteUserCustomTest(RemoteUserTest): """ backend =\ - 'django.contrib.auth.tests.remote_user.CustomRemoteUserBackend' + 'django.contrib.auth.tests.test_remote_user.CustomRemoteUserBackend' # REMOTE_USER strings with email addresses for the custom backend to # clean. known_user = 'knownuser@example.com' diff --git a/django/contrib/auth/tests/signals.py b/django/contrib/auth/tests/test_signals.py similarity index 100% rename from django/contrib/auth/tests/signals.py rename to django/contrib/auth/tests/test_signals.py diff --git a/django/contrib/auth/tests/tokens.py b/django/contrib/auth/tests/test_tokens.py similarity index 100% rename from django/contrib/auth/tests/tokens.py rename to django/contrib/auth/tests/test_tokens.py diff --git a/django/contrib/auth/tests/views.py b/django/contrib/auth/tests/test_views.py similarity index 100% rename from django/contrib/auth/tests/views.py rename to django/contrib/auth/tests/test_views.py