Added tests for utils.html.urlize() (lazy string inputs were untested).

This commit is contained in:
Tim Graham 2018-02-10 15:45:57 -05:00 committed by GitHub
parent 919d59811f
commit b832de869e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 1 deletions

View File

@ -5,7 +5,7 @@ from django.test import SimpleTestCase
from django.utils.functional import lazystr from django.utils.functional import lazystr
from django.utils.html import ( from django.utils.html import (
conditional_escape, escape, escapejs, format_html, html_safe, json_script, 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 from django.utils.safestring import mark_safe
@ -238,3 +238,18 @@ class TestUtilsHtml(SimpleTestCase):
@html_safe @html_safe
class HtmlClass: class HtmlClass:
pass 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)