Ticket #14478: 14478.diff

File 14478.diff, 3.6 KB (added by Claude Paroz, 13 years ago)

Improved tests in current trunk

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

    diff --git a/django/contrib/messages/tests/base.py b/django/contrib/messages/tests/base.py
    index 8d04532..64fe1ed 100644
    a b  
    11from django import http
    2 from django.conf import settings
     2from django.conf import settings, global_settings
    33from django.contrib.messages import constants, utils, get_level, set_level
    44from django.contrib.messages.api import MessageFailure
    55from django.contrib.messages.storage import default_storage, base
    class BaseTest(TestCase):  
    5757    def setUp(self):
    5858        self.settings_override = override_settings_tags(
    5959            TEMPLATE_DIRS   = (),
     60            TEMPLATE_CONTEXT_PROCESSORS = global_settings.TEMPLATE_CONTEXT_PROCESSORS,
    6061            MESSAGE_TAGS    = '',
    6162            MESSAGE_STORAGE = '%s.%s' % (self.storage_class.__module__,
    6263                                         self.storage_class.__name__),
  • django/contrib/sitemaps/tests/basic.py

    diff --git a/django/contrib/sitemaps/tests/basic.py b/django/contrib/sitemaps/tests/basic.py
    index 775e0d9..319ac94 100644
    a b from django.contrib.sitemaps import Sitemap, GenericSitemap  
    66from django.contrib.sites.models import Site
    77from django.core.exceptions import ImproperlyConfigured
    88from django.test import TestCase
     9from django.test.utils import override_settings
    910from django.utils.unittest import skipUnless
    1011from django.utils.formats import localize
    1112from django.utils.translation import activate, deactivate
    class SitemapTests(TestCase):  
    1920            self.base_url = 'http://example.com'
    2021        else:
    2122            self.base_url = 'http://testserver'
    22         self.old_USE_L10N = settings.USE_L10N
    2323        self.old_Site_meta_installed = Site._meta.installed
    24         self.old_TEMPLATE_DIRS = settings.TEMPLATE_DIRS
    25         self.old_Site_meta_installed = Site._meta.installed
    26         settings.TEMPLATE_DIRS = (
    27             os.path.join(os.path.dirname(__file__), 'templates'),
    28         )
    2924        # Create a user that will double as sitemap content
    3025        User.objects.create_user('testuser', 'test@example.com', 's3krit')
    3126
    3227    def tearDown(self):
    33         settings.USE_L10N = self.old_USE_L10N
    34         Site._meta.installed = self.old_Site_meta_installed
    35         settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS
    3628        Site._meta.installed = self.old_Site_meta_installed
    3729
    3830    def test_simple_sitemap_index(self):
    class SitemapTests(TestCase):  
    4638</sitemapindex>
    4739""" % self.base_url)
    4840
     41    @override_settings(
     42        TEMPLATE_DIRS=(os.path.join(os.path.dirname(__file__), 'templates'),))
    4943    def test_simple_sitemap_custom_index(self):
    5044        "A simple sitemap index can be rendered with a custom template"
    5145        # Retrieve the sitemap.
    class SitemapTests(TestCase):  
    6963</urlset>
    7064""" % (self.base_url, date.today()))
    7165
     66    @override_settings(
     67        TEMPLATE_DIRS=(os.path.join(os.path.dirname(__file__), 'templates'),))
    7268    def test_simple_custom_sitemap(self):
    7369        "A simple sitemap can be rendered with a custom template"
    7470        # Retrieve the sitemap.
    class SitemapTests(TestCase):  
    8278""" % (self.base_url, date.today()))
    8379
    8480    @skipUnless(settings.USE_I18N, "Internationalization is not enabled")
     81    @override_settings(USE_L10N=True)
    8582    def test_localized_priority(self):
    8683        "The priority value should not be localized (Refs #14164)"
    87         # Localization should be active
    88         settings.USE_L10N = True
    8984        activate('fr')
    9085        self.assertEqual(u'0,3', localize(0.3))
    9186
Back to Top