summaryrefslogtreecommitdiff
path: root/tests/utils_tests/test_html.py
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2018-02-10 15:45:57 -0500
committerGitHub <noreply@github.com>2018-02-10 15:45:57 -0500
commitb832de869eb6a7ada946bbe1c1a8228e153e254a (patch)
treeb1db705fd0011dae15c26b4e167b621b78ba86c2 /tests/utils_tests/test_html.py
parent919d59811f10f5a0101aac7b854aad5ec13d1b2a (diff)
Added tests for utils.html.urlize() (lazy string inputs were untested).
Diffstat (limited to 'tests/utils_tests/test_html.py')
-rw-r--r--tests/utils_tests/test_html.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/tests/utils_tests/test_html.py b/tests/utils_tests/test_html.py
index e2ebce4556..4f0cc8d459 100644
--- a/tests/utils_tests/test_html.py
+++ b/tests/utils_tests/test_html.py
@@ -5,7 +5,7 @@ from django.test import SimpleTestCase
from django.utils.functional import lazystr
from django.utils.html import (
conditional_escape, escape, escapejs, format_html, html_safe, json_script,
- linebreaks, smart_urlquote, strip_spaces_between_tags, strip_tags,
+ linebreaks, smart_urlquote, strip_spaces_between_tags, strip_tags, urlize,
)
from django.utils.safestring import mark_safe
@@ -238,3 +238,18 @@ class TestUtilsHtml(SimpleTestCase):
@html_safe
class HtmlClass:
pass
+
+ def test_urlize(self):
+ tests = (
+ (
+ 'Search for google.com/?q=! and see.',
+ 'Search for <a href="http://google.com/?q=">google.com/?q=</a>! and see.'
+ ),
+ (
+ lazystr('Search for google.com/?q=!'),
+ 'Search for <a href="http://google.com/?q=">google.com/?q=</a>!'
+ ),
+ )
+ for value, output in tests:
+ with self.subTest(value=value):
+ self.assertEqual(urlize(value), output)