1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

Fixed #33924 -- Deprecated BaseGeometryWidget.map_height/map_width attributes.

This commit is contained in:
Claude Paroz
2022-08-12 12:18:51 +02:00
committed by Mariusz Felisiak
parent 8c3046daad
commit 4fcba800b8
8 changed files with 53 additions and 3 deletions

View File

@@ -5,6 +5,7 @@ from django.contrib.gis.forms import BaseGeometryWidget, OpenLayersWidget
from django.contrib.gis.geos import GEOSGeometry
from django.core.exceptions import ValidationError
from django.test import SimpleTestCase, override_settings
from django.utils.deprecation import RemovedInDjango51Warning
from django.utils.html import escape
@@ -485,3 +486,19 @@ class GeometryWidgetTests(SimpleTestCase):
form = PointForm(data={"p": point.json})
self.assertTrue(form.is_valid())
self.assertEqual(form.cleaned_data["p"].srid, 4326)
def test_deprecated_width_and_height(self):
class CustomGeometryWidget(forms.BaseGeometryWidget):
map_height = 300
map_width = 550
msg = (
"The map_height and map_width widget attributes are deprecated. Please use "
"CSS to size map widgets."
)
with self.assertRaisesMessage(RemovedInDjango51Warning, msg):
CustomGeometryWidget()
with self.assertRaisesMessage(RemovedInDjango51Warning, msg):
forms.BaseGeometryWidget({"map_width": 400})
with self.assertRaisesMessage(RemovedInDjango51Warning, msg):
forms.BaseGeometryWidget({"map_height": 600})