@@ -640,6 +640,78 @@ def test_max_lines_long(self):
640640 max_lines = 4 )
641641
642642
643+ class LongWordWithHyphensTestCase (BaseTestCase ):
644+ def setUp (self ):
645+ self .wrapper = TextWrapper ()
646+ self .text1 = '''\
647+ We used enyzme 2-succinyl-6-hydroxy-2,4-cyclohexadiene-1-carboxylate synthase.
648+ '''
649+ self .text2 = '''\
650+ 1234567890-1234567890--this_is_a_very_long_option_indeed-good-bye"
651+ '''
652+
653+ def test_break_long_words_on_hyphen (self ):
654+ expected = ['We used enyzme 2-succinyl-6-hydroxy-2,4-' ,
655+ 'cyclohexadiene-1-carboxylate synthase.' ]
656+ self .check_wrap (self .text1 , 50 , expected )
657+
658+ expected = ['We used' , 'enyzme 2-' , 'succinyl-' , '6-hydroxy-' , '2,4-' ,
659+ 'cyclohexad' , 'iene-1-' , 'carboxylat' , 'e' , 'synthase.' ]
660+ self .check_wrap (self .text1 , 10 , expected )
661+
662+ expected = ['1234567890' , '-123456789' , '0--this_is' , '_a_very_lo' ,
663+ 'ng_option_' , 'indeed-' , 'good-bye"' ]
664+ self .check_wrap (self .text2 , 10 , expected )
665+
666+ def test_break_long_words_not_on_hyphen (self ):
667+ expected = ['We used enyzme 2-succinyl-6-hydroxy-2,4-cyclohexad' ,
668+ 'iene-1-carboxylate synthase.' ]
669+ self .check_wrap (self .text1 , 50 , expected , break_on_hyphens = False )
670+
671+ expected = ['We used' , 'enyzme 2-s' , 'uccinyl-6-' , 'hydroxy-2,' ,
672+ '4-cyclohex' , 'adiene-1-c' , 'arboxylate' , 'synthase.' ]
673+ self .check_wrap (self .text1 , 10 , expected , break_on_hyphens = False )
674+
675+ expected = ['1234567890' , '-123456789' , '0--this_is' , '_a_very_lo' ,
676+ 'ng_option_' , 'indeed-' , 'good-bye"' ]
677+ self .check_wrap (self .text2 , 10 , expected )
678+
679+ def test_break_on_hyphen_but_not_long_words (self ):
680+ expected = ['We used enyzme' ,
681+ '2-succinyl-6-hydroxy-2,4-cyclohexadiene-1-carboxylate' ,
682+ 'synthase.' ]
683+
684+ self .check_wrap (self .text1 , 50 , expected , break_long_words = False )
685+
686+ expected = ['We used' , 'enyzme' ,
687+ '2-succinyl-6-hydroxy-2,4-cyclohexadiene-1-carboxylate' ,
688+ 'synthase.' ]
689+ self .check_wrap (self .text1 , 10 , expected , break_long_words = False )
690+
691+ expected = ['1234567890' , '-123456789' , '0--this_is' , '_a_very_lo' ,
692+ 'ng_option_' , 'indeed-' , 'good-bye"' ]
693+ self .check_wrap (self .text2 , 10 , expected )
694+
695+
696+ def test_do_not_break_long_words_or_on_hyphens (self ):
697+ expected = ['We used enyzme' ,
698+ '2-succinyl-6-hydroxy-2,4-cyclohexadiene-1-carboxylate' ,
699+ 'synthase.' ]
700+ self .check_wrap (self .text1 , 50 , expected ,
701+ break_long_words = False ,
702+ break_on_hyphens = False )
703+
704+ expected = ['We used' , 'enyzme' ,
705+ '2-succinyl-6-hydroxy-2,4-cyclohexadiene-1-carboxylate' ,
706+ 'synthase.' ]
707+ self .check_wrap (self .text1 , 10 , expected ,
708+ break_long_words = False ,
709+ break_on_hyphens = False )
710+
711+ expected = ['1234567890' , '-123456789' , '0--this_is' , '_a_very_lo' ,
712+ 'ng_option_' , 'indeed-' , 'good-bye"' ]
713+ self .check_wrap (self .text2 , 10 , expected )
714+
643715class IndentTestCases (BaseTestCase ):
644716
645717 # called before each test method
0 commit comments