Ticket #14632: issue14632.1.diff

File issue14632.1.diff, 3.0 KB (added by Gregor Müllegger, 14 years ago)

Skipping tests that depend on working User.objects.create(...)

  • django/contrib/messages/tests/base.py

    diff --git a/django/contrib/messages/tests/base.py b/django/contrib/messages/tests/base.py
    index 9c6132b..9a0f7fb 100644
    a b from django import http  
    44from django.test import TestCase
    55from django.conf import settings
    66from django.utils.translation import ugettext_lazy
     7from django.utils.unittest import skipIf
    78from django.contrib.messages import constants, utils, get_level, set_level
    89from django.contrib.messages.api import MessageFailure
    910from django.contrib.messages.storage import default_storage, base
    from django.core.urlresolvers import reverse  
    1213from django.contrib.auth.models import User
    1314
    1415
     16def skipUnlessAuthIsInstalled(func):
     17    return skipIf(
     18        'django.contrib.auth' not in settings.INSTALLED_APPS,
     19        "django.contrib.auth isn't installed")(func)
     20
     21
    1522def add_level_messages(storage):
    1623    """
    1724    Adds 6 messages from different levels (including a custom one) to a storage
    class BaseTest(TestCase):  
    196203        for msg in data['messages']:
    197204            self.assertContains(response, msg)
    198205
     206    @skipUnlessAuthIsInstalled
    199207    def test_middleware_disabled_auth_user(self):
    200208        """
    201209        Tests that the messages API successfully falls back to using
  • django/contrib/messages/tests/session.py

    diff --git a/django/contrib/messages/tests/session.py b/django/contrib/messages/tests/session.py
    index 741f531..44fa96c 100644
    a b  
    11from django.contrib.messages.tests.base import BaseTest
     2from django.contrib.messages.tests.base import skipUnlessAuthIsInstalled
    23from django.contrib.messages.storage.session import SessionStorage
    34
    45
  • django/contrib/messages/tests/user_messages.py

    diff --git a/django/contrib/messages/tests/user_messages.py b/django/contrib/messages/tests/user_messages.py
    index 8d7aeb7..dad552c 100644
    a b from django import http  
    22from django.contrib.auth.models import User
    33from django.contrib.messages.storage.user_messages import UserMessagesStorage,\
    44    LegacyFallbackStorage
     5from django.contrib.messages.tests.base import skipUnlessAuthIsInstalled
    56from django.contrib.messages.tests.cookie import set_cookie_data
    67from django.contrib.messages.tests.fallback import FallbackTest
    78from django.test import TestCase
    class UserMessagesTest(TestCase):  
    3031        self.assertEqual(len(storage), 1)
    3132        self.assertEqual(list(storage)[0].message, 'test message')
    3233
     34UserMessagesTest = skipUnlessAuthIsInstalled(UserMessagesTest)
     35
    3336
    3437class LegacyFallbackTest(FallbackTest, TestCase):
    3538    storage_class = LegacyFallbackStorage
    class LegacyFallbackTest(FallbackTest, TestCase):  
    6366        self.assertEqual(len(storage), 2)
    6467        self.assertEqual(list(storage)[0].message, 'user message')
    6568        self.assertEqual(list(storage)[1], 'cookie')
     69
     70LegacyFallbackTest = skipUnlessAuthIsInstalled(LegacyFallbackTest)
Back to Top