| 196 | ) |
| 197 | |
| 198 | def test_truncate_words(self): |
| 199 | truncator = text.Truncator("The quick brown fox jumped over the lazy dog.") |
| 200 | self.assertEqual( |
| 201 | "The quick brown fox jumped over the lazy dog.", truncator.words(10) |
| 202 | ) |
| 203 | self.assertEqual("The quick brown fox…", truncator.words(4)) |
| 204 | self.assertEqual("The quick brown fox[snip]", truncator.words(4, "[snip]")) |
| 205 | # lazy strings are handled correctly |
| 206 | truncator = text.Truncator( |
| 207 | lazystr("The quick brown fox jumped over the lazy dog.") |
| 208 | ) |
| 209 | self.assertEqual("The quick brown fox…", truncator.words(4)) |
| 210 | self.assertEqual("", truncator.words(0)) |
| 211 | self.assertEqual("", truncator.words(-1)) |
| 212 | |
| 213 | def test_truncate_html_words(self): |
| 214 | truncator = text.Truncator( |