mirror of
https://github.com/django/django.git
synced 2025-10-25 06:36:07 +00:00
Used the override_settings decorator in the tests of auth, flatpages, and formtools.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17851 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -3,6 +3,7 @@ from django.contrib.auth.models import User, Group, Permission, AnonymousUser
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.test import TestCase
|
||||
from django.test.utils import override_settings
|
||||
|
||||
|
||||
class BackendTest(TestCase):
|
||||
@@ -230,20 +231,14 @@ class AnonymousUserBackendTest(TestCase):
|
||||
self.assertEqual(self.user1.get_all_permissions(TestObj()), set(['anon']))
|
||||
|
||||
|
||||
|
||||
|
||||
@override_settings(AUTHENTICATION_BACKENDS=[])
|
||||
class NoBackendsTest(TestCase):
|
||||
"""
|
||||
Tests that an appropriate error is raised if no auth backends are provided.
|
||||
"""
|
||||
def setUp(self):
|
||||
self.old_AUTHENTICATION_BACKENDS = settings.AUTHENTICATION_BACKENDS
|
||||
settings.AUTHENTICATION_BACKENDS = []
|
||||
self.user = User.objects.create_user('test', 'test@example.com', 'test')
|
||||
|
||||
def tearDown(self):
|
||||
settings.AUTHENTICATION_BACKENDS = self.old_AUTHENTICATION_BACKENDS
|
||||
|
||||
def test_raises_exception(self):
|
||||
self.assertRaises(ImproperlyConfigured, self.user.has_perm, ('perm', TestObj(),))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user