Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
  • Loading branch information...
commit ff63a5bdeca3b88751a1e54a0cbc8adbb2c682eb 1 parent 9b7be91
Jannis Leidel authored November 13, 2010
8  django/contrib/messages/tests/base.py
@@ -4,6 +4,7 @@
4 4
 from django.test import TestCase
5 5
 from django.conf import settings
6 6
 from django.utils.translation import ugettext_lazy
  7
+from django.utils.unittest import skipIf
7 8
 from django.contrib.messages import constants, utils, get_level, set_level
8 9
 from django.contrib.messages.api import MessageFailure
9 10
 from django.contrib.messages.storage import default_storage, base
@@ -12,6 +13,12 @@
12 13
 from django.contrib.auth.models import User
13 14
 
14 15
 
  16
+def skipUnlessAuthIsInstalled(func):
  17
+    return skipIf(
  18
+        'django.contrib.auth' not in settings.INSTALLED_APPS,
  19
+        "django.contrib.auth isn't installed")(func)
  20
+
  21
+
15 22
 def add_level_messages(storage):
16 23
     """
17 24
     Adds 6 messages from different levels (including a custom one) to a storage
@@ -196,6 +203,7 @@ def test_multiple_posts(self):
196 203
         for msg in data['messages']:
197 204
             self.assertContains(response, msg)
198 205
 
  206
+    @skipUnlessAuthIsInstalled
199 207
     def test_middleware_disabled_auth_user(self):
200 208
         """
201 209
         Tests that the messages API successfully falls back to using
5  django/contrib/messages/tests/user_messages.py
@@ -2,6 +2,7 @@
2 2
 from django.contrib.auth.models import User
3 3
 from django.contrib.messages.storage.user_messages import UserMessagesStorage,\
4 4
     LegacyFallbackStorage
  5
+from django.contrib.messages.tests.base import skipUnlessAuthIsInstalled
5 6
 from django.contrib.messages.tests.cookie import set_cookie_data
6 7
 from django.contrib.messages.tests.fallback import FallbackTest
7 8
 from django.test import TestCase
@@ -30,6 +31,8 @@ def test_get(self):
30 31
         self.assertEqual(len(storage), 1)
31 32
         self.assertEqual(list(storage)[0].message, 'test message')
32 33
 
  34
+UserMessagesTest = skipUnlessAuthIsInstalled(UserMessagesTest)
  35
+
33 36
 
34 37
 class LegacyFallbackTest(FallbackTest, TestCase):
35 38
     storage_class = LegacyFallbackStorage
@@ -63,3 +66,5 @@ def test_get_legacy(self):
63 66
         self.assertEqual(len(storage), 2)
64 67
         self.assertEqual(list(storage)[0].message, 'user message')
65 68
         self.assertEqual(list(storage)[1], 'cookie')
  69
+
  70
+LegacyFallbackTest = skipUnlessAuthIsInstalled(LegacyFallbackTest)

0 notes on commit ff63a5b

Please sign in to comment.
Something went wrong with that request. Please try again.