mirror of https://github.com/django/django.git
Silenced some GIS deprecation warnings; refs #22384.
This commit is contained in:
parent
1a01e24331
commit
250e2b422b
|
@ -3,6 +3,7 @@ from __future__ import unicode_literals
|
|||
from io import BytesIO
|
||||
from unittest import skipUnless
|
||||
from xml.dom import minidom
|
||||
import warnings
|
||||
import zipfile
|
||||
|
||||
from django.conf import settings
|
||||
|
@ -10,6 +11,7 @@ from django.contrib.gis.geos import HAS_GEOS
|
|||
from django.contrib.gis.tests.utils import HAS_SPATIAL_DB
|
||||
from django.contrib.sites.models import Site
|
||||
from django.test import TestCase, modify_settings, override_settings
|
||||
from django.utils.deprecation import RemovedInDjango20Warning
|
||||
|
||||
if HAS_GEOS:
|
||||
from .models import City, Country
|
||||
|
@ -33,7 +35,16 @@ class GeoSitemapTest(TestCase):
|
|||
def test_geositemap_kml(self):
|
||||
"Tests KML/KMZ geographic sitemaps."
|
||||
for kml_type in ('kml', 'kmz'):
|
||||
doc = minidom.parseString(self.client.get('/sitemaps/%s.xml' % kml_type).content)
|
||||
with warnings.catch_warnings():
|
||||
warnings.filterwarnings("ignore", category=RemovedInDjango20Warning)
|
||||
# The URL for the sitemaps in urls.py have 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.gis.sitemaps.views.(kml|kmz)', we need
|
||||
# to silence the erroneous warning until reversing by dotted
|
||||
# path is removed. The test will work without modification when
|
||||
# it's removed.
|
||||
doc = minidom.parseString(self.client.get('/sitemaps/%s.xml' % kml_type).content)
|
||||
|
||||
# Ensuring the right sitemaps namespace is present.
|
||||
urlset = doc.firstChild
|
||||
|
|
|
@ -18,6 +18,10 @@ urlpatterns += [
|
|||
]
|
||||
|
||||
urlpatterns += [
|
||||
url(r'^sitemaps/kml/(?P<label>\w+)/(?P<model>\w+)/(?P<field_name>\w+)\.kml$', gis_sitemap_views.kml),
|
||||
url(r'^sitemaps/kml/(?P<label>\w+)/(?P<model>\w+)/(?P<field_name>\w+)\.kmz$', gis_sitemap_views.kmz),
|
||||
url(r'^sitemaps/kml/(?P<label>\w+)/(?P<model>\w+)/(?P<field_name>\w+)\.kml$',
|
||||
gis_sitemap_views.kml,
|
||||
name='django.contrib.gis.sitemaps.views.kml'),
|
||||
url(r'^sitemaps/kml/(?P<label>\w+)/(?P<model>\w+)/(?P<field_name>\w+)\.kmz$',
|
||||
gis_sitemap_views.kmz,
|
||||
name='django.contrib.gis.sitemaps.views.kmz'),
|
||||
]
|
||||
|
|
|
@ -383,4 +383,7 @@ the ``url`` that references :func:`django.contrib.sitemaps.views.sitemap`::
|
|||
|
||||
to ensure compatibility when reversing by Python path is removed in Django 2.0.
|
||||
|
||||
Similarly for GIS sitemaps, add ``name='django.contrib.gis.sitemaps.views.kml'``
|
||||
or ``name='django.contrib.gis.sitemaps.views.kmz'``.
|
||||
|
||||
.. _security issue: https://www.djangoproject.com/weblog/2014/apr/21/security/#s-issue-unexpected-code-execution-using-reverse
|
||||
|
|
Loading…
Reference in New Issue