summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic Bistuer <loic.bistuer@gmail.com>2014-09-19 05:40:51 +0700
committerLoic Bistuer <loic.bistuer@gmail.com>2014-09-27 00:42:47 +0700
commit45840927d3516770be2654422e752357d5c063a5 (patch)
tree30d675912cbe7044b63a522e1c72f8e153c23cfd
parentb23d47412c12352ba2e2133b05a15ccd09e81af3 (diff)
Silenced some deprecation warnings in contrib.sitemaps; refs #22384.
-rw-r--r--django/contrib/sitemaps/tests/test_http.py32
-rw-r--r--django/contrib/sitemaps/tests/test_https.py12
-rw-r--r--django/contrib/sitemaps/tests/urls/http.py40
-rw-r--r--django/contrib/sitemaps/tests/urls/https.py3
4 files changed, 70 insertions, 17 deletions
diff --git a/django/contrib/sitemaps/tests/test_http.py b/django/contrib/sitemaps/tests/test_http.py
index cf0cc38732..045570e660 100644
--- a/django/contrib/sitemaps/tests/test_http.py
+++ b/django/contrib/sitemaps/tests/test_http.py
@@ -3,6 +3,7 @@ from __future__ import unicode_literals
import os
from datetime import date
from unittest import skipUnless
+import warnings
from django.apps import apps
from django.conf import settings
@@ -10,6 +11,7 @@ from django.contrib.sitemaps import Sitemap, GenericSitemap
from django.contrib.sites.models import Site
from django.core.exceptions import ImproperlyConfigured
from django.test import modify_settings, override_settings
+from django.utils.deprecation import RemovedInDjango20Warning
from django.utils.formats import localize
from django.utils._os import upath
from django.utils.translation import activate, deactivate
@@ -21,7 +23,15 @@ class HTTPSitemapTests(SitemapTestsBase):
def test_simple_sitemap_index(self):
"A simple sitemap index can be rendered"
- response = self.client.get('/simple/index.xml')
+ with warnings.catch_warnings():
+ warnings.filterwarnings("ignore", category=RemovedInDjango20Warning)
+ # The URL for views.sitemap in tests/urls/http.py has been updated
+ # with a name but since reversing by Python path is tried first
+ # before reversing by name and works since we're giving
+ # name='django.contrib.sitemaps.views.sitemap', we need to silence
+ # the erroneous warning until reversing by dotted path is removed.
+ # The test will work without modification when it's removed.
+ response = self.client.get('/simple/index.xml')
expected_content = """<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap><loc>%s/simple/sitemap-simple.xml</loc></sitemap>
@@ -34,7 +44,15 @@ class HTTPSitemapTests(SitemapTestsBase):
)
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')
+ with warnings.catch_warnings():
+ warnings.filterwarnings("ignore", category=RemovedInDjango20Warning)
+ # The URL for views.sitemap in tests/urls/http.py has been updated
+ # with a name but since reversing by Python path is tried first
+ # before reversing by name and works since we're giving
+ # name='django.contrib.sitemaps.views.sitemap', we need to silence
+ # the erroneous warning until reversing by dotted path is removed.
+ # The test will work without modification when it's removed.
+ response = self.client.get('/simple/custom-index.xml')
expected_content = """<?xml version="1.0" encoding="UTF-8"?>
<!-- This is a customised template -->
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
@@ -177,7 +195,15 @@ class HTTPSitemapTests(SitemapTestsBase):
self.assertXMLEqual(response.content.decode('utf-8'), expected_content)
def test_x_robots_sitemap(self):
- response = self.client.get('/simple/index.xml')
+ with warnings.catch_warnings():
+ warnings.filterwarnings("ignore", category=RemovedInDjango20Warning)
+ # The URL for views.sitemap in tests/urls/http.py has been updated
+ # with a name but since reversing by Python path is tried first
+ # before reversing by name and works since we're giving
+ # name='django.contrib.sitemaps.views.sitemap', we need to silence
+ # the erroneous warning until reversing by dotted path is removed.
+ # The test will work without modification when it's removed.
+ response = self.client.get('/simple/index.xml')
self.assertEqual(response['X-Robots-Tag'], 'noindex, noodp, noarchive')
response = self.client.get('/simple/sitemap.xml')
diff --git a/django/contrib/sitemaps/tests/test_https.py b/django/contrib/sitemaps/tests/test_https.py
index 3de6b7bb35..66d44d9554 100644
--- a/django/contrib/sitemaps/tests/test_https.py
+++ b/django/contrib/sitemaps/tests/test_https.py
@@ -15,7 +15,15 @@ class HTTPSSitemapTests(SitemapTestsBase):
def test_secure_sitemap_index(self):
"A secure sitemap index can be rendered"
- response = self.client.get('/secure/index.xml')
+ with warnings.catch_warnings():
+ warnings.filterwarnings("ignore", category=RemovedInDjango20Warning)
+ # The URL for views.sitemap in tests/urls/https.py has been updated
+ # with a name but since reversing by Python path is tried first
+ # before reversing by name and works since we're giving
+ # name='django.contrib.sitemaps.views.sitemap', we need to silence
+ # the erroneous warning until reversing by dotted path is removed.
+ # The test will work without modification when it's removed.
+ response = self.client.get('/secure/index.xml')
expected_content = """<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap><loc>%s/secure/sitemap-simple.xml</loc></sitemap>
@@ -42,7 +50,7 @@ class HTTPSDetectionSitemapTests(SitemapTestsBase):
"A sitemap index requested in HTTPS is rendered with HTTPS links"
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=RemovedInDjango20Warning)
- # The URL for views.sitemap in tests/urls/http.py has been updated
+ # The URL for views.sitemap in tests/urls/https.py has been updated
# with a name but since reversing by Python path is tried first
# before reversing by name and works since we're giving
# name='django.contrib.sitemaps.views.sitemap', we need to silence
diff --git a/django/contrib/sitemaps/tests/urls/http.py b/django/contrib/sitemaps/tests/urls/http.py
index 87bbb1e509..07da79045e 100644
--- a/django/contrib/sitemaps/tests/urls/http.py
+++ b/django/contrib/sitemaps/tests/urls/http.py
@@ -100,20 +100,38 @@ urlpatterns = [
url(r'^simple/custom-index\.xml$', views.index,
{'sitemaps': simple_sitemaps, 'template_name': 'custom_sitemap_index.xml'}),
url(r'^simple/sitemap-(?P<section>.+)\.xml$', views.sitemap,
- {'sitemaps': simple_sitemaps}, name='django.contrib.sitemaps.views.sitemap'),
- url(r'^simple/sitemap\.xml$', views.sitemap, {'sitemaps': simple_sitemaps}),
- url(r'^simple/i18n\.xml$', views.sitemap, {'sitemaps': simple_i18nsitemaps}),
+ {'sitemaps': simple_sitemaps},
+ name='django.contrib.sitemaps.views.sitemap'),
+ url(r'^simple/sitemap\.xml$', views.sitemap,
+ {'sitemaps': simple_sitemaps},
+ name='django.contrib.sitemaps.views.sitemap'),
+ url(r'^simple/i18n\.xml$', views.sitemap,
+ {'sitemaps': simple_i18nsitemaps},
+ name='django.contrib.sitemaps.views.sitemap'),
url(r'^simple/custom-sitemap\.xml$', views.sitemap,
- {'sitemaps': simple_sitemaps, 'template_name': 'custom_sitemap.xml'}),
- url(r'^empty/sitemap\.xml$', views.sitemap, {'sitemaps': empty_sitemaps}),
- url(r'^lastmod/sitemap\.xml$', views.sitemap, {'sitemaps': fixed_lastmod_sitemaps}),
- url(r'^lastmod-mixed/sitemap\.xml$', views.sitemap, {'sitemaps': fixed_lastmod__mixed_sitemaps}),
+ {'sitemaps': simple_sitemaps, 'template_name': 'custom_sitemap.xml'},
+ name='django.contrib.sitemaps.views.sitemap'),
+ url(r'^empty/sitemap\.xml$', views.sitemap,
+ {'sitemaps': empty_sitemaps},
+ name='django.contrib.sitemaps.views.sitemap'),
+ url(r'^lastmod/sitemap\.xml$', views.sitemap,
+ {'sitemaps': fixed_lastmod_sitemaps},
+ name='django.contrib.sitemaps.views.sitemap'),
+ url(r'^lastmod-mixed/sitemap\.xml$', views.sitemap,
+ {'sitemaps': fixed_lastmod__mixed_sitemaps},
+ name='django.contrib.sitemaps.views.sitemap'),
url(r'^lastmod/date-sitemap.xml$', views.sitemap,
- {'sitemaps': {'date-sitemap': DateSiteMap}}),
+ {'sitemaps': {'date-sitemap': DateSiteMap}},
+ name='django.contrib.sitemaps.views.sitemap'),
url(r'^lastmod/tz-sitemap.xml$', views.sitemap,
- {'sitemaps': {'tz-sitemap': TimezoneSiteMap}}),
- url(r'^generic/sitemap\.xml$', views.sitemap, {'sitemaps': generic_sitemaps}),
- url(r'^flatpages/sitemap\.xml$', views.sitemap, {'sitemaps': flatpage_sitemaps}),
+ {'sitemaps': {'tz-sitemap': TimezoneSiteMap}},
+ name='django.contrib.sitemaps.views.sitemap'),
+ url(r'^generic/sitemap\.xml$', views.sitemap,
+ {'sitemaps': generic_sitemaps},
+ name='django.contrib.sitemaps.views.sitemap'),
+ url(r'^flatpages/sitemap\.xml$', views.sitemap,
+ {'sitemaps': flatpage_sitemaps},
+ name='django.contrib.sitemaps.views.sitemap'),
url(r'^cached/index\.xml$', cache_page(1)(views.index),
{'sitemaps': simple_sitemaps, 'sitemap_url_name': 'cached_sitemap'}),
url(r'^cached/sitemap-(?P<section>.+)\.xml', cache_page(1)(views.sitemap),
diff --git a/django/contrib/sitemaps/tests/urls/https.py b/django/contrib/sitemaps/tests/urls/https.py
index abadc6c739..ec4ab1489f 100644
--- a/django/contrib/sitemaps/tests/urls/https.py
+++ b/django/contrib/sitemaps/tests/urls/https.py
@@ -14,5 +14,6 @@ secure_sitemaps = {
urlpatterns = [
url(r'^secure/index\.xml$', views.index, {'sitemaps': secure_sitemaps}),
url(r'^secure/sitemap-(?P<section>.+)\.xml$', views.sitemap,
- {'sitemaps': secure_sitemaps}),
+ {'sitemaps': secure_sitemaps},
+ name='django.contrib.sitemaps.views.sitemap'),
]