From 6ee37ada3241ed263d8d1c2901b030d964cbd161 Mon Sep 17 00:00:00 2001
From: David Smith The quick brown fox jumped over the lazy dog.'
+ ' The quick brown fox jumped over the lazy dog…'
" … Joel is a slug
Joel is a…
"), # 10 chars ] for value, expected in perf_test_values: with self.subTest(value=value): truncator = text.Truncator(value) - self.assertEqual( - expected if expected else value, truncator.chars(10, html=True) - ) + self.assertEqual(expected, truncator.chars(10, html=True)) def test_truncate_chars_html_with_newline_inside_tag(self): truncator = text.Truncator( @@ -181,7 +179,7 @@ class TestUtilsText(SimpleTestCase): "I <3 python, what about you?
") - self.assertEqual("I <3 python,…
", truncator.chars(16, html=True)) + self.assertEqual("I <3 python, wh…
", truncator.chars(16, html=True)) def test_truncate_words(self): truncator = text.Truncator("The quick brown fox jumped over the lazy dog.") @@ -242,7 +248,7 @@ class TestUtilsText(SimpleTestCase): "The quick \t brown fox jumped over the lazy dog.
" ) self.assertEqual( - "The quick \t brown fox…
", + "The quick brown fox…
", truncator.words(4, html=True), ) @@ -277,7 +283,7 @@ class TestUtilsText(SimpleTestCase): "Buenos días! ¿Cómo está?" ) self.assertEqual( - "Buenos días! ¿Cómo…", + "Buenos días! ¿Cómo…", truncator.words(3, html=True), ) truncator = text.Truncator("I <3 python, what about you?
") @@ -292,19 +298,17 @@ class TestUtilsText(SimpleTestCase): bigger_len = text.Truncator.MAX_LENGTH_HTML + 1 valid_html = "Joel is a slug
" # 4 words perf_test_values = [ - ("", None), - ("", "", None), + ("", ""), + ("", ""), + ("&" * max_len, ""), + ("&" * bigger_len, ""), + ("_X<<<<<<<<<<<>", "_X<<<<<<<<<<<>"), (valid_html * bigger_len, valid_html * 12 + "Joel is…
"), # 50 words ] for value, expected in perf_test_values: with self.subTest(value=value): truncator = text.Truncator(value) - self.assertEqual( - expected if expected else value, truncator.words(50, html=True) - ) + self.assertEqual(expected, truncator.words(50, html=True)) def test_wrap(self): digits = "1234 67 9" -- cgit v1.3