From 4a5753fb0af28967c9ad6a5be8966cdbd933ad64 Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Wed, 17 May 2023 16:11:43 +0200 Subject: [PATCH] Refs #32339 -- Fixed super() call in deprecated renderers. Missing function call `()` leads to: TypeError: descriptor '__init__' of 'super' object needs an argument Regression in b209518089131c6b4afd18b1d9c320ba3521c5ab. --- django/forms/renderers.py | 4 ++-- tests/forms_tests/tests/test_renderers.py | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/django/forms/renderers.py b/django/forms/renderers.py index 58abe9ed02..970d05804c 100644 --- a/django/forms/renderers.py +++ b/django/forms/renderers.py @@ -81,7 +81,7 @@ class DjangoDivFormRenderer(DjangoTemplates): "DjangoTemplates instead.", RemovedInDjango60Warning, ) - super.__init__(*args, **kwargs) + super().__init__(*args, **kwargs) # RemovedInDjango60Warning. @@ -97,7 +97,7 @@ class Jinja2DivFormRenderer(Jinja2): "Jinja2 instead.", RemovedInDjango60Warning, ) - super.__init__(*args, **kwargs) + super().__init__(*args, **kwargs) class TemplatesSetting(BaseRenderer): diff --git a/tests/forms_tests/tests/test_renderers.py b/tests/forms_tests/tests/test_renderers.py index 54e20626af..dbde6df49d 100644 --- a/tests/forms_tests/tests/test_renderers.py +++ b/tests/forms_tests/tests/test_renderers.py @@ -9,7 +9,7 @@ from django.forms.renderers import ( Jinja2DivFormRenderer, TemplatesSetting, ) -from django.test import SimpleTestCase +from django.test import SimpleTestCase, ignore_warnings from django.utils.deprecation import RemovedInDjango60Warning try: @@ -74,3 +74,11 @@ class DeprecationTests(SimpleTestCase): ) with self.assertRaisesMessage(RemovedInDjango60Warning, msg): Jinja2DivFormRenderer() + + @ignore_warnings(category=RemovedInDjango60Warning) + def test_deprecation_renderers_can_be_instantiated(self): + tests = [DjangoDivFormRenderer, Jinja2DivFormRenderer] + for cls in tests: + with self.subTest(renderer_class=cls): + renderer = cls() + self.assertIsInstance(renderer, cls)