test_utils.py 555 B

1234567891011121314
  1. from __future__ import unicode_literals
  2. from html5lib_truncation.utils import truncate_sentence
  3. def test_truncate_sentence():
  4. s = 'Three Rings for the Elven-kings under the sky'
  5. assert truncate_sentence(s, 18) == 'Three Rings for'
  6. assert truncate_sentence(s, 18, break_words=True) == 'Three Rings for th'
  7. assert truncate_sentence(s, 18, break_words=False) == 'Three Rings for'
  8. assert truncate_sentence(s, 18, break_words=True, padding=9) == 'Three Rin'
  9. assert truncate_sentence(s, 18, break_words=False, padding=9) == 'Three'