@@ -636,9 +636,28 @@ def test_max_lines_long(self):
636636 ['Did you say' ,
637637 '"supercalifr' ,
638638 'agilisticexp' ,
639- '[...]' ],
639+ 'ialido [...]' ],
640640 max_lines = 4 )
641641
642+ def test_max_lines_long_word_broken (self ):
643+ # A long word broken across lines is broken further on the last
644+ # line to make room for the placeholder, instead of dropping the
645+ # whole remaining piece.
646+ self .check_wrap ('x' * 30 , 10 ,
647+ ['xxxxxxxxxx' , 'xxxx [...]' ],
648+ max_lines = 2 )
649+ self .check_wrap ('x' * 30 , 10 ,
650+ ['xxxx [...]' ],
651+ max_lines = 1 )
652+ # Not enough room for the placeholder plus any text: the
653+ # placeholder-only line is kept.
654+ self .check_wrap ('x' * 30 , 5 ,
655+ ['xxxxx' , '[...]' ],
656+ max_lines = 2 )
657+ self .check_wrap ('x' * 30 , 10 ,
658+ ['xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' ],
659+ max_lines = 2 , break_long_words = False )
660+
642661
643662class LongWordWithHyphensTestCase (BaseTestCase ):
644663 def setUp (self ):
@@ -1132,6 +1151,16 @@ def test_width_too_small_for_placeholder(self):
11321151 def test_first_word_too_long_but_placeholder_fits (self ):
11331152 self .check_shorten ("Helloo" , 5 , "[...]" )
11341153
1154+ def test_long_word_broken_to_fit_placeholder (self ):
1155+ # A single word longer than the width is broken further to make
1156+ # room for the placeholder, instead of being replaced by it alone.
1157+ self .check_shorten ("x" * 30 , 10 , "xxxx [...]" )
1158+ self .check_shorten ("x" * 30 , 20 , "xxxxxxxxxxxxxx [...]" )
1159+ # Not enough room for the placeholder plus any text.
1160+ self .check_shorten ("x" * 30 , 5 , "[...]" )
1161+ # Words are only broken when break_long_words is true.
1162+ self .check_shorten ("x" * 30 , 10 , "[...]" , break_long_words = False )
1163+
11351164
11361165if __name__ == '__main__' :
11371166 unittest .main ()
0 commit comments