Fixed #14632 -- Skip a messages test if auth app is not in INSTALLED_APPS. Thanks, gregmuellegger.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14557 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
9b7be918ed
commit
ff63a5bdec
|
@ -4,6 +4,7 @@ from django import http
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.utils.translation import ugettext_lazy
|
from django.utils.translation import ugettext_lazy
|
||||||
|
from django.utils.unittest import skipIf
|
||||||
from django.contrib.messages import constants, utils, get_level, set_level
|
from django.contrib.messages import constants, utils, get_level, set_level
|
||||||
from django.contrib.messages.api import MessageFailure
|
from django.contrib.messages.api import MessageFailure
|
||||||
from django.contrib.messages.storage import default_storage, base
|
from django.contrib.messages.storage import default_storage, base
|
||||||
|
@ -12,6 +13,12 @@ from django.core.urlresolvers import reverse
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
|
|
||||||
|
|
||||||
|
def skipUnlessAuthIsInstalled(func):
|
||||||
|
return skipIf(
|
||||||
|
'django.contrib.auth' not in settings.INSTALLED_APPS,
|
||||||
|
"django.contrib.auth isn't installed")(func)
|
||||||
|
|
||||||
|
|
||||||
def add_level_messages(storage):
|
def add_level_messages(storage):
|
||||||
"""
|
"""
|
||||||
Adds 6 messages from different levels (including a custom one) to a storage
|
Adds 6 messages from different levels (including a custom one) to a storage
|
||||||
|
@ -196,6 +203,7 @@ class BaseTest(TestCase):
|
||||||
for msg in data['messages']:
|
for msg in data['messages']:
|
||||||
self.assertContains(response, msg)
|
self.assertContains(response, msg)
|
||||||
|
|
||||||
|
@skipUnlessAuthIsInstalled
|
||||||
def test_middleware_disabled_auth_user(self):
|
def test_middleware_disabled_auth_user(self):
|
||||||
"""
|
"""
|
||||||
Tests that the messages API successfully falls back to using
|
Tests that the messages API successfully falls back to using
|
||||||
|
|
|
@ -2,6 +2,7 @@ from django import http
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.contrib.messages.storage.user_messages import UserMessagesStorage,\
|
from django.contrib.messages.storage.user_messages import UserMessagesStorage,\
|
||||||
LegacyFallbackStorage
|
LegacyFallbackStorage
|
||||||
|
from django.contrib.messages.tests.base import skipUnlessAuthIsInstalled
|
||||||
from django.contrib.messages.tests.cookie import set_cookie_data
|
from django.contrib.messages.tests.cookie import set_cookie_data
|
||||||
from django.contrib.messages.tests.fallback import FallbackTest
|
from django.contrib.messages.tests.fallback import FallbackTest
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
@ -30,6 +31,8 @@ class UserMessagesTest(TestCase):
|
||||||
self.assertEqual(len(storage), 1)
|
self.assertEqual(len(storage), 1)
|
||||||
self.assertEqual(list(storage)[0].message, 'test message')
|
self.assertEqual(list(storage)[0].message, 'test message')
|
||||||
|
|
||||||
|
UserMessagesTest = skipUnlessAuthIsInstalled(UserMessagesTest)
|
||||||
|
|
||||||
|
|
||||||
class LegacyFallbackTest(FallbackTest, TestCase):
|
class LegacyFallbackTest(FallbackTest, TestCase):
|
||||||
storage_class = LegacyFallbackStorage
|
storage_class = LegacyFallbackStorage
|
||||||
|
@ -63,3 +66,5 @@ class LegacyFallbackTest(FallbackTest, TestCase):
|
||||||
self.assertEqual(len(storage), 2)
|
self.assertEqual(len(storage), 2)
|
||||||
self.assertEqual(list(storage)[0].message, 'user message')
|
self.assertEqual(list(storage)[0].message, 'user message')
|
||||||
self.assertEqual(list(storage)[1], 'cookie')
|
self.assertEqual(list(storage)[1], 'cookie')
|
||||||
|
|
||||||
|
LegacyFallbackTest = skipUnlessAuthIsInstalled(LegacyFallbackTest)
|
||||||
|
|
Loading…
Reference in New Issue