0
0
mirror of https://github.com/django/django.git synced 2024-11-21 19:09:18 +01:00

Refs #32339 -- Adjusted deprecation warning stacklevel in transitional form renderers.

This commit is contained in:
Simon Charette 2024-08-09 12:32:50 -04:00 committed by nessita
parent 6bd5d4f705
commit 7e6e1c8383
2 changed files with 6 additions and 2 deletions

View File

@ -80,6 +80,7 @@ class DjangoDivFormRenderer(DjangoTemplates):
"The DjangoDivFormRenderer transitional form renderer is deprecated. Use "
"DjangoTemplates instead.",
RemovedInDjango60Warning,
stacklevel=2,
)
super().__init__(*args, **kwargs)
@ -96,6 +97,7 @@ class Jinja2DivFormRenderer(Jinja2):
"The Jinja2DivFormRenderer transitional form renderer is deprecated. Use "
"Jinja2 instead.",
RemovedInDjango60Warning,
stacklevel=2,
)
super().__init__(*args, **kwargs)

View File

@ -64,16 +64,18 @@ class DeprecationTests(SimpleTestCase):
"The DjangoDivFormRenderer transitional form renderer is deprecated. Use "
"DjangoTemplates instead."
)
with self.assertRaisesMessage(RemovedInDjango60Warning, msg):
with self.assertWarnsMessage(RemovedInDjango60Warning, msg) as ctx:
DjangoDivFormRenderer()
self.assertEqual(ctx.filename, __file__)
def test_jinja2_div_renderer_warning(self):
msg = (
"The Jinja2DivFormRenderer transitional form renderer is deprecated. Use "
"Jinja2 instead."
)
with self.assertRaisesMessage(RemovedInDjango60Warning, msg):
with self.assertWarnsMessage(RemovedInDjango60Warning, msg) as ctx:
Jinja2DivFormRenderer()
self.assertEqual(ctx.filename, __file__)
@ignore_warnings(category=RemovedInDjango60Warning)
def test_deprecation_renderers_can_be_instantiated(self):