Commit 250e2b42 authored by Tim Graham's avatar Tim Graham
Browse files

Silenced some GIS deprecation warnings; refs #22384.

parent 1a01e243
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -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,6 +35,15 @@ class GeoSitemapTest(TestCase):
    def test_geositemap_kml(self):
        "Tests KML/KMZ geographic sitemaps."
        for kml_type in ('kml', 'kmz'):
            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.
+6 −2
Original line number Diff line number Diff line
@@ -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'),
]
+3 −0
Original line number Diff line number Diff line
@@ -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