From 231c0d85931b5afde3e3caec0e6bc5ca6132bb7a Mon Sep 17 00:00:00 2001 From: nabil-rady Date: Wed, 14 Aug 2024 00:58:37 +0300 Subject: Fixed #35668 -- Added mapping support to format_html_join. --- tests/utils_tests/test_html.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'tests/utils_tests/test_html.py') diff --git a/tests/utils_tests/test_html.py b/tests/utils_tests/test_html.py index 82dbd58f12..f6373e3048 100644 --- a/tests/utils_tests/test_html.py +++ b/tests/utils_tests/test_html.py @@ -10,6 +10,7 @@ from django.utils.html import ( escape, escapejs, format_html, + format_html_join, html_safe, json_script, linebreaks, @@ -75,6 +76,26 @@ class TestUtilsHtml(SimpleTestCase): name = "Adam" self.assertEqual(format_html(f"{name}"), "Adam") + def test_format_html_join_with_positional_arguments(self): + self.assertEqual( + format_html_join( + "\n", + "
  • {}) {}
  • ", + [(1, "Emma"), (2, "Matilda")], + ), + "
  • 1) Emma
  • \n
  • 2) Matilda
  • ", + ) + + def test_format_html_join_with_keyword_arguments(self): + self.assertEqual( + format_html_join( + "\n", + "
  • {id}) {text}
  • ", + [{"id": 1, "text": "Emma"}, {"id": 2, "text": "Matilda"}], + ), + "
  • 1) Emma
  • \n
  • 2) Matilda
  • ", + ) + def test_linebreaks(self): items = ( ("para1\n\npara2\r\rpara3", "

    para1

    \n\n

    para2

    \n\n

    para3

    "), -- cgit v1.3