diff options
| author | nabil-rady <midorady9999@gmail.com> | 2024-08-14 00:58:37 +0300 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2024-08-20 08:20:34 +0200 |
| commit | 231c0d85931b5afde3e3caec0e6bc5ca6132bb7a (patch) | |
| tree | 8f7fbb7deb54c15507852eec31740f2a1a7adfbf /tests/utils_tests/test_html.py | |
| parent | ca1318988c68f623ab12ab4ddb04eabb8afe5a33 (diff) | |
Fixed #35668 -- Added mapping support to format_html_join.
Diffstat (limited to 'tests/utils_tests/test_html.py')
| -rw-r--r-- | tests/utils_tests/test_html.py | 21 |
1 files changed, 21 insertions, 0 deletions
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"<i>{name}</i>"), "<i>Adam</i>") + def test_format_html_join_with_positional_arguments(self): + self.assertEqual( + format_html_join( + "\n", + "<li>{}) {}</li>", + [(1, "Emma"), (2, "Matilda")], + ), + "<li>1) Emma</li>\n<li>2) Matilda</li>", + ) + + def test_format_html_join_with_keyword_arguments(self): + self.assertEqual( + format_html_join( + "\n", + "<li>{id}) {text}</li>", + [{"id": 1, "text": "Emma"}, {"id": 2, "text": "Matilda"}], + ), + "<li>1) Emma</li>\n<li>2) Matilda</li>", + ) + def test_linebreaks(self): items = ( ("para1\n\npara2\r\rpara3", "<p>para1</p>\n\n<p>para2</p>\n\n<p>para3</p>"), |
