Loading django/utils/text.py +1 −1 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ capfirst = lambda x: x and force_text(x)[0].upper() + force_text(x)[1:] capfirst = allow_lazy(capfirst, six.text_type) # Set up regular expressions re_words = re.compile(r'&.*?;|<.*?>|(\w[\w-]*)', re.U|re.S) re_words = re.compile(r'<.*?>|((?:\w[-\w]*|&.*?;)+)', re.U|re.S) re_tag = re.compile(r'<(/)?([^ ]+?)(?:(\s*/)| .*?)?>', re.S) Loading tests/defaultfilters/tests.py +3 −0 Original line number Diff line number Diff line Loading @@ -184,6 +184,9 @@ class DefaultFiltersTests(TestCase): '<p>one <a href="#">two - three <br>four</a> five</p>') self.assertEqual(truncatewords_html( '\xc5ngstr\xf6m was here', 1), '\xc5ngstr\xf6m ...') self.assertEqual(truncatewords_html('<i>Buenos días! ' '¿Cómo está?</i>', 3), '<i>Buenos días! ¿Cómo ...</i>') def test_upper(self): self.assertEqual(upper('Mixed case input'), 'MIXED CASE INPUT') Loading tests/utils_tests/test_text.py +9 −0 Original line number Diff line number Diff line Loading @@ -82,6 +82,15 @@ class TestUtilsText(SimpleTestCase): self.assertEqual('<br>The <hr/>quick <em>brown...</em>', truncator.words(3, '...', html=True )) # Test html entities truncator = text.Truncator('<i>Buenos días!' ' ¿Cómo está?</i>') self.assertEqual('<i>Buenos días! ¿Cómo...</i>', truncator.words(3, '...', html=True)) truncator = text.Truncator('<p>I <3 python, what about you?</p>') self.assertEqual('<p>I <3 python...</p>', truncator.words(3, '...', html=True)) def test_wrap(self): digits = '1234 67 9' self.assertEqual(text.wrap(digits, 100), '1234 67 9') Loading Loading
django/utils/text.py +1 −1 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ capfirst = lambda x: x and force_text(x)[0].upper() + force_text(x)[1:] capfirst = allow_lazy(capfirst, six.text_type) # Set up regular expressions re_words = re.compile(r'&.*?;|<.*?>|(\w[\w-]*)', re.U|re.S) re_words = re.compile(r'<.*?>|((?:\w[-\w]*|&.*?;)+)', re.U|re.S) re_tag = re.compile(r'<(/)?([^ ]+?)(?:(\s*/)| .*?)?>', re.S) Loading
tests/defaultfilters/tests.py +3 −0 Original line number Diff line number Diff line Loading @@ -184,6 +184,9 @@ class DefaultFiltersTests(TestCase): '<p>one <a href="#">two - three <br>four</a> five</p>') self.assertEqual(truncatewords_html( '\xc5ngstr\xf6m was here', 1), '\xc5ngstr\xf6m ...') self.assertEqual(truncatewords_html('<i>Buenos días! ' '¿Cómo está?</i>', 3), '<i>Buenos días! ¿Cómo ...</i>') def test_upper(self): self.assertEqual(upper('Mixed case input'), 'MIXED CASE INPUT') Loading
tests/utils_tests/test_text.py +9 −0 Original line number Diff line number Diff line Loading @@ -82,6 +82,15 @@ class TestUtilsText(SimpleTestCase): self.assertEqual('<br>The <hr/>quick <em>brown...</em>', truncator.words(3, '...', html=True )) # Test html entities truncator = text.Truncator('<i>Buenos días!' ' ¿Cómo está?</i>') self.assertEqual('<i>Buenos días! ¿Cómo...</i>', truncator.words(3, '...', html=True)) truncator = text.Truncator('<p>I <3 python, what about you?</p>') self.assertEqual('<p>I <3 python...</p>', truncator.words(3, '...', html=True)) def test_wrap(self): digits = '1234 67 9' self.assertEqual(text.wrap(digits, 100), '1234 67 9') Loading