parts/django/tests/regressiontests/utils/text.py
changeset 69 c6bca38c1cbf
equal deleted inserted replaced
68:5ff1fc726848 69:c6bca38c1cbf
       
     1 import unittest
       
     2 
       
     3 from django.utils import text
       
     4 
       
     5 class TestUtilsText(unittest.TestCase):
       
     6     def test_truncate_words(self):
       
     7         self.assertEqual(u'The quick brown fox jumped over the lazy dog.',
       
     8             text.truncate_words(u'The quick brown fox jumped over the lazy dog.', 10))
       
     9         self.assertEqual(u'The quick brown fox ...',
       
    10             text.truncate_words('The quick brown fox jumped over the lazy dog.', 4))
       
    11         self.assertEqual(u'The quick brown fox ....',
       
    12             text.truncate_words('The quick brown fox jumped over the lazy dog.', 4, '....'))
       
    13         self.assertEqual(u'<p><strong><em>The quick brown fox jumped over the lazy dog.</em></strong></p>',
       
    14             text.truncate_html_words('<p><strong><em>The quick brown fox jumped over the lazy dog.</em></strong></p>', 10))
       
    15         self.assertEqual(u'<p><strong><em>The quick brown fox ...</em></strong></p>',
       
    16             text.truncate_html_words('<p><strong><em>The quick brown fox jumped over the lazy dog.</em></strong></p>', 4))
       
    17         self.assertEqual(u'<p><strong><em>The quick brown fox ....</em></strong></p>',
       
    18             text.truncate_html_words('<p><strong><em>The quick brown fox jumped over the lazy dog.</em></strong></p>', 4, '....'))
       
    19         self.assertEqual(u'<p><strong><em>The quick brown fox</em></strong></p>',
       
    20             text.truncate_html_words('<p><strong><em>The quick brown fox jumped over the lazy dog.</em></strong></p>', 4, None))