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

Fixed #34609 -- Deprecated calling format_html() without arguments.

This commit is contained in:
devilsautumn
2023-06-06 14:26:53 +05:30
committed by Mariusz Felisiak
parent 4f6a51dfe6
commit 094b0bea2c
5 changed files with 30 additions and 0 deletions

View File

@@ -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):
"&lt; Dangerous &gt; <b>safe</b> &lt; dangerous again <i>safe again</i>",
)
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"<i>{name}</i>"), "<i>Adam</i>")
def test_linebreaks(self):
items = (
("para1\n\npara2\r\rpara3", "<p>para1</p>\n\n<p>para2</p>\n\n<p>para3</p>"),