diff --git a/django/contrib/gis/maps/google/gmap.py b/django/contrib/gis/maps/google/gmap.py
index 75b285ca76b..ff6562696dc 100644
--- a/django/contrib/gis/maps/google/gmap.py
+++ b/django/contrib/gis/maps/google/gmap.py
@@ -134,7 +134,8 @@ class GoogleMap(object):
@property
def scripts(self):
"Returns all tags required with Google Maps JavaScript."
- return format_html('%s\n ', self.api_script, mark_safe(self.js))
+ return format_html('{0}\n ',
+ self.api_script, mark_safe(self.js))
@property
def style(self):
diff --git a/django/contrib/gis/tests/geoadmin/tests.py b/django/contrib/gis/tests/geoadmin/tests.py
index 6fadebdb9a8..ecd387d2f48 100644
--- a/django/contrib/gis/tests/geoadmin/tests.py
+++ b/django/contrib/gis/tests/geoadmin/tests.py
@@ -1,11 +1,14 @@
from __future__ import absolute_import
-from django.test import TestCase
from django.contrib.gis import admin
from django.contrib.gis.geos import GEOSGeometry, Point
+from django.test import TestCase
+from django.test.utils import override_settings
from .models import City
+GOOGLE_MAPS_API_KEY = 'XXXX'
+
class GeoAdminTest(TestCase):
urls = 'django.contrib.gis.tests.geoadmin.urls'
@@ -35,7 +38,9 @@ class GeoAdminTest(TestCase):
result)
def test_olwidget_has_changed(self):
- """ Check that changes are accurately noticed by OpenLayersWidget. """
+ """
+ Check that changes are accurately noticed by OpenLayersWidget.
+ """
geoadmin = admin.site._registry[City]
form = geoadmin.get_changelist_form(None)()
has_changed = form.fields['point'].widget._has_changed
@@ -51,3 +56,15 @@ class GeoAdminTest(TestCase):
self.assertFalse(has_changed(initial, data_same))
self.assertFalse(has_changed(initial, data_almost_same))
self.assertTrue(has_changed(initial, data_changed))
+
+ @override_settings(GOOGLE_MAPS_API_KEY=GOOGLE_MAPS_API_KEY)
+ def test_google_map_scripts(self):
+ """
+ Testing GoogleMap.scripts() output. See #20773.
+ """
+ from django.contrib.gis.maps.google.gmap import GoogleMap
+
+ google_map = GoogleMap()
+ scripts = google_map.scripts
+ self.assertIn(GOOGLE_MAPS_API_KEY, scripts)
+ self.assertIn("new GMap2", scripts)