From b8bf5950b6a6c684196a6d047d41efbff0f95c85 Mon Sep 17 00:00:00 2001 From: "(GalaxyMaster)" Date: Wed, 12 Jul 2023 19:28:26 +1000 Subject: [PATCH] Adding missing tests for truncate_html_words() (#2918) --- pelican/tests/test_utils.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pelican/tests/test_utils.py b/pelican/tests/test_utils.py index 1890ffb96..2dab2ab44 100644 --- a/pelican/tests/test_utils.py +++ b/pelican/tests/test_utils.py @@ -259,6 +259,26 @@ def test_truncate_html_words(self): utils.truncate_html_words('' + 'word ' * 100, 20), '' + 'word ' * 20 + '…') + # Words enclosed or intervaled by HTML tags with a custom end + # marker containing HTML tags. + self.assertEqual( + utils.truncate_html_words('

' + 'word ' * 100 + '

', 20, + 'marker'), + '

' + 'word ' * 20 + 'marker

') + self.assertEqual( + utils.truncate_html_words( + '' + 'word ' * 100 + '', 20, + 'marker'), + '' + 'word ' * 20 + 'marker') + self.assertEqual( + utils.truncate_html_words('
' + 'word ' * 100, 20, + 'marker'), + '
' + 'word ' * 20 + 'marker') + self.assertEqual( + utils.truncate_html_words('' + 'word ' * 100, 20, + 'marker'), + '' + 'word ' * 20 + 'marker') + # Words with hypens and apostrophes. self.assertEqual( utils.truncate_html_words("a-b " * 100, 20),