Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Modified auth to work with unittest2 discovery.

  • Loading branch information...
commit fde2e4fd6ecdf6aa9c31d004f91be2b8df76ddb9 1 parent e3cfbaa
@prestontimmons prestontimmons authored carljm committed
View
41 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)
View
10 django/contrib/auth/tests/auth_backends.py → django/contrib/auth/tests/test_auth_backends.py
@@ -4,7 +4,7 @@
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')
View
14 django/contrib/auth/tests/basic.py → django/contrib/auth/tests/test_basic.py
@@ -6,17 +6,29 @@
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
View
0  django/contrib/auth/tests/context_processors.py → django/contrib/auth/tests/test_context_processors.py
File renamed without changes
View
0  django/contrib/auth/tests/custom_user.py → django/contrib/auth/tests/test_custom_user.py
File renamed without changes
View
2  django/contrib/auth/tests/decorators.py → 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
View
0  django/contrib/auth/tests/forms.py → django/contrib/auth/tests/test_forms.py
File renamed without changes
View
0  django/contrib/auth/tests/handlers.py → django/contrib/auth/tests/test_handlers.py
File renamed without changes
View
0  django/contrib/auth/tests/hashers.py → django/contrib/auth/tests/test_hashers.py
File renamed without changes
View
0  django/contrib/auth/tests/management.py → django/contrib/auth/tests/test_management.py
File renamed without changes
View
0  django/contrib/auth/tests/models.py → django/contrib/auth/tests/test_models.py
File renamed without changes
View
4 django/contrib/auth/tests/remote_user.py → django/contrib/auth/tests/test_remote_user.py
@@ -137,7 +137,7 @@ class that doesn't create unknown users.
"""
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'
View
0  django/contrib/auth/tests/signals.py → django/contrib/auth/tests/test_signals.py
File renamed without changes
View
0  django/contrib/auth/tests/tokens.py → django/contrib/auth/tests/test_tokens.py
File renamed without changes
View
0  django/contrib/auth/tests/views.py → django/contrib/auth/tests/test_views.py
File renamed without changes
Please sign in to comment.
Something went wrong with that request. Please try again.