MCPcopy
hub / github.com/django/django / test_truncate_words

Method test_truncate_words

tests/utils_tests/test_text.py:198–211  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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(

Callers

nothing calls this directly

Calls 2

wordsMethod · 0.95
lazystrFunction · 0.90

Tested by

no test coverage detected