Code

Ticket #3714: text-wrap-with-tests.patch

File text-wrap-with-tests.patch, 1.3 KB (added by clelland@…, 7 years ago)

Same patch, now with doctests

  • django/utils/text.py

     
    1717        pos = len(word) - word.rfind('\n') - 1 
    1818        for word in it: 
    1919            if "\n" in word: 
    20                 lines = word.splitlines() 
     20                lines = word.split('\n') 
    2121            else: 
    2222                lines = (word,) 
    2323            pos += len(lines[0]) + 1 
  • tests/regressiontests/defaultfilters/tests.py

     
    133133>>> wordwrap('this is a long paragraph of text that really needs to be wrapped I\'m afraid', 14) 
    134134"this is a long\nparagraph of\ntext that\nreally needs\nto be wrapped\nI'm afraid" 
    135135 
     136>>> wordwrap('this is a short paragraph of text.\n  But this line should be indented',14) 
     137'this is a\nshort\nparagraph of\ntext.\n  But this\nline should be\nindented' 
     138 
     139>>> wordwrap('this is a short paragraph of text.\n  But this line should be indented',15) 
     140'this is a short\nparagraph of\ntext.\n  But this line\nshould be\nindented' 
     141 
    136142>>> ljust('test', 10) 
    137143'test      ' 
    138144