diff options
| author | Chris Beaven <smileychris@gmail.com> | 2010-11-30 21:21:37 +0000 |
|---|---|---|
| committer | Chris Beaven <smileychris@gmail.com> | 2010-11-30 21:21:37 +0000 |
| commit | e4b0a8f93c7cff2da06090726567944fcf7d04d7 (patch) | |
| tree | 9d74070d4af7055badf5160965241a2f4f571c3b | |
| parent | a77fad23c255582c3a2e56ae20b50d27e6c8eac7 (diff) | |
Tests for utils.text.wrap
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14752 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | tests/regressiontests/utils/text.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/regressiontests/utils/text.py b/tests/regressiontests/utils/text.py index e7d2d38d3b..f565d87b1d 100644 --- a/tests/regressiontests/utils/text.py +++ b/tests/regressiontests/utils/text.py @@ -3,6 +3,7 @@ import unittest from django.utils import text class TestUtilsText(unittest.TestCase): + def test_truncate_words(self): self.assertEqual(u'The quick brown fox jumped over the lazy dog.', text.truncate_words(u'The quick brown fox jumped over the lazy dog.', 10)) @@ -10,6 +11,8 @@ class TestUtilsText(unittest.TestCase): text.truncate_words('The quick brown fox jumped over the lazy dog.', 4)) self.assertEqual(u'The quick brown fox ....', text.truncate_words('The quick brown fox jumped over the lazy dog.', 4, '....')) + + def test_truncate_html_words(self): self.assertEqual(u'<p><strong><em>The quick brown fox jumped over the lazy dog.</em></strong></p>', text.truncate_html_words('<p><strong><em>The quick brown fox jumped over the lazy dog.</em></strong></p>', 10)) self.assertEqual(u'<p><strong><em>The quick brown fox ...</em></strong></p>', @@ -18,3 +21,20 @@ class TestUtilsText(unittest.TestCase): text.truncate_html_words('<p><strong><em>The quick brown fox jumped over the lazy dog.</em></strong></p>', 4, '....')) self.assertEqual(u'<p><strong><em>The quick brown fox</em></strong></p>', text.truncate_html_words('<p><strong><em>The quick brown fox jumped over the lazy dog.</em></strong></p>', 4, None)) + + def test_wrap(self): + digits = '1234 67 9' + self.assertEqual(text.wrap(digits, 100), u'1234 67 9') + self.assertEqual(text.wrap(digits, 9), u'1234 67 9') + self.assertEqual(text.wrap(digits, 8), u'1234 67\n9') + + self.assertEqual(text.wrap('short\na long line', 7), + u'short\na long\nline') + + self.assertEqual(text.wrap('do-not-break-long-words please? ok', 8), + u'do-not-break-long-words\nplease?\nok') + + long_word = 'l%sng' % ('o' * 20) + self.assertEqual(text.wrap(long_word, 20), long_word) + self.assertEqual(text.wrap('a %s word' % long_word, 10), + u'a\n%s\nword' % long_word) |
