From 7676d6e764c47c9d33a755c3b861034b32de77ac Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Sat, 2 Jun 2012 21:24:18 +0200 Subject: [PATCH] Made sitemaps tests use override_settings. Refs #14478 --- django/contrib/sitemaps/tests/base.py | 10 ---------- django/contrib/sitemaps/tests/http.py | 13 +++++++++++-- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/django/contrib/sitemaps/tests/base.py b/django/contrib/sitemaps/tests/base.py index f1d6753b3a..224277e2a0 100644 --- a/django/contrib/sitemaps/tests/base.py +++ b/django/contrib/sitemaps/tests/base.py @@ -1,6 +1,3 @@ -import os - -from django.conf import settings from django.contrib.auth.models import User from django.contrib.sites.models import Site from django.test import TestCase @@ -13,16 +10,9 @@ class SitemapTestsBase(TestCase): def setUp(self): self.base_url = '%s://%s' % (self.protocol, self.domain) - self.old_USE_L10N = settings.USE_L10N - self.old_TEMPLATE_DIRS = settings.TEMPLATE_DIRS - settings.TEMPLATE_DIRS = ( - os.path.join(os.path.dirname(__file__), 'templates'), - ) self.old_Site_meta_installed = Site._meta.installed # Create a user that will double as sitemap content User.objects.create_user('testuser', 'test@example.com', 's3krit') def tearDown(self): - settings.USE_L10N = self.old_USE_L10N - settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS Site._meta.installed = self.old_Site_meta_installed diff --git a/django/contrib/sitemaps/tests/http.py b/django/contrib/sitemaps/tests/http.py index 3b56aa8d53..5786aa48d5 100644 --- a/django/contrib/sitemaps/tests/http.py +++ b/django/contrib/sitemaps/tests/http.py @@ -1,15 +1,19 @@ +import os from datetime import date + from django.conf import settings from django.contrib.auth.models import User from django.contrib.sitemaps import Sitemap, GenericSitemap from django.contrib.sites.models import Site from django.core.exceptions import ImproperlyConfigured +from django.test.utils import override_settings from django.utils.unittest import skipUnless from django.utils.formats import localize from django.utils.translation import activate, deactivate from .base import SitemapTestsBase + class HTTPSitemapTests(SitemapTestsBase): def test_simple_sitemap_index(self): @@ -21,6 +25,9 @@ class HTTPSitemapTests(SitemapTestsBase): """ % self.base_url) + @override_settings( + TEMPLATE_DIRS=(os.path.join(os.path.dirname(__file__), 'templates'),) + ) def test_simple_sitemap_custom_index(self): "A simple sitemap index can be rendered with a custom template" response = self.client.get('/simple/custom-index.xml') @@ -49,6 +56,9 @@ class HTTPSitemapTests(SitemapTestsBase): """ % (self.base_url, date.today())) + @override_settings( + TEMPLATE_DIRS=(os.path.join(os.path.dirname(__file__), 'templates'),) + ) def test_simple_custom_sitemap(self): "A simple sitemap can be rendered with a custom template" response = self.client.get('/simple/custom-sitemap.xml') @@ -60,10 +70,9 @@ class HTTPSitemapTests(SitemapTestsBase): """ % (self.base_url, date.today())) @skipUnless(settings.USE_I18N, "Internationalization is not enabled") + @override_settings(USE_L10N=True) def test_localized_priority(self): "The priority value should not be localized (Refs #14164)" - # Localization should be active - settings.USE_L10N = True activate('fr') self.assertEqual(u'0,3', localize(0.3))