1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #28105 -- Fixed crash in BaseGeometryWidget.get_context() when overriding existing attrs.

This commit is contained in:
Dylan Verheul
2017-04-29 15:35:46 +02:00
committed by Tim Graham
parent 1ebd295082
commit 75aeebebfe
3 changed files with 20 additions and 9 deletions

View File

@@ -1,6 +1,7 @@
import re
from django.contrib.gis import forms
from django.contrib.gis.forms import BaseGeometryWidget
from django.contrib.gis.geos import GEOSGeometry
from django.forms import ValidationError
from django.test import SimpleTestCase, override_settings, skipUnlessDBFeature
@@ -353,6 +354,12 @@ class OSMWidgetTest(SimpleTestCase):
@skipUnlessDBFeature("gis_enabled")
class GeometryWidgetTests(SimpleTestCase):
def test_get_context_attrs(self):
"""The Widget.get_context() attrs argument overrides self.attrs."""
widget = BaseGeometryWidget(attrs={'geom_type': 'POINT'})
context = widget.get_context('point', None, attrs={'geom_type': 'POINT2'})
self.assertEqual(context['geom_type'], 'POINT2')
def test_subwidgets(self):
widget = forms.BaseGeometryWidget()
self.assertEqual(