Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Made sitemaps tests use override_settings. Refs #14478

  • Loading branch information...
commit 7676d6e764c47c9d33a755c3b861034b32de77ac 1 parent 566ac30
@claudep claudep authored
View
10 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
View
13 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 @@ def test_simple_sitemap_index(self):
</sitemapindex>
""" % 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 @@ def test_simple_sitemap(self):
</urlset>
""" % (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 @@ def test_simple_custom_sitemap(self):
""" % (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))
Please sign in to comment.
Something went wrong with that request. Please try again.