From 973502c04704aac4742e2d996cb758acd5035d46 Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Mon, 2 Sep 2013 14:15:04 +0200 Subject: [PATCH] Fixed gis test to run on non gis-enabled settings Refs #20998. --- django/contrib/gis/tests/test_geoforms.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/django/contrib/gis/tests/test_geoforms.py b/django/contrib/gis/tests/test_geoforms.py index 9d17756096..e476ffccbd 100644 --- a/django/contrib/gis/tests/test_geoforms.py +++ b/django/contrib/gis/tests/test_geoforms.py @@ -247,25 +247,26 @@ class SpecializedFieldTest(SimpleTestCase): @skipUnless(HAS_GDAL and HAS_SPATIALREFSYS, "CustomGeometryWidgetTest needs gdal support and a spatial database") class CustomGeometryWidgetTest(SimpleTestCase): - class CustomGeometryWidget(forms.BaseGeometryWidget): - template_name = 'gis/openlayers.html' - deserialize_called = 0 - def serialize(self, value): - return value.json if value else '' - - def deserialize(self, value): - self.deserialize_called += 1 - return GEOSGeometry(value) def test_custom_serialization_widget(self): + class CustomGeometryWidget(forms.BaseGeometryWidget): + template_name = 'gis/openlayers.html' + deserialize_called = 0 + def serialize(self, value): + return value.json if value else '' + + def deserialize(self, value): + self.deserialize_called += 1 + return GEOSGeometry(value) + class PointForm(forms.Form): - p = forms.PointField(widget=self.CustomGeometryWidget) + p = forms.PointField(widget=CustomGeometryWidget) point = GEOSGeometry("SRID=4326;POINT(9.052734375 42.451171875)") form = PointForm(data={'p': point}) self.assertIn(escape(point.json), form.as_p()) - self.CustomGeometryWidget.called = 0 + CustomGeometryWidget.called = 0 widget = form.fields['p'].widget # Force deserialize use due to a string value self.assertIn(escape(point.json), widget.render('p', point.json))