From 094b0bea2ce76db9d3dc06c384d4ac3b22705810 Mon Sep 17 00:00:00 2001 From: devilsautumn Date: Tue, 6 Jun 2023 14:26:53 +0530 Subject: Fixed #34609 -- Deprecated calling format_html() without arguments. --- tests/utils_tests/test_html.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests/utils_tests') diff --git a/tests/utils_tests/test_html.py b/tests/utils_tests/test_html.py index b7a7396075..ad31b8cc5b 100644 --- a/tests/utils_tests/test_html.py +++ b/tests/utils_tests/test_html.py @@ -3,6 +3,7 @@ from datetime import datetime from django.core.serializers.json import DjangoJSONEncoder from django.test import SimpleTestCase +from django.utils.deprecation import RemovedInDjango60Warning from django.utils.functional import lazystr from django.utils.html import ( conditional_escape, @@ -65,6 +66,15 @@ class TestUtilsHtml(SimpleTestCase): "< Dangerous > safe < dangerous again safe again", ) + def test_format_html_no_params(self): + msg = "Calling format_html() without passing args or kwargs is deprecated." + # RemovedInDjango60Warning: when the deprecation ends, replace with: + # msg = "args or kwargs must be provided." + # with self.assertRaisesMessage(ValueError, msg): + with self.assertWarnsMessage(RemovedInDjango60Warning, msg): + name = "Adam" + self.assertEqual(format_html(f"{name}"), "Adam") + def test_linebreaks(self): items = ( ("para1\n\npara2\r\rpara3", "

para1

\n\n

para2

\n\n

para3

"), -- cgit v1.3