From: Jonathan Eunice Date: Wed, 7 Jun 2017 20:49:13 +0000 (-0400) Subject: bpo-30591: Added test for textwrap backtracking. (#1988) X-Git-Tag: v3.7.0a1~672 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5edf827c8052958b9d293f75ce8d93b66c1d58da;p=python bpo-30591: Added test for textwrap backtracking. (#1988) --- diff --git a/Lib/test/test_textwrap.py b/Lib/test/test_textwrap.py index 5a33c15164..47d97bda86 100644 --- a/Lib/test/test_textwrap.py +++ b/Lib/test/test_textwrap.py @@ -559,6 +559,17 @@ class MaxLinesTestCase(BaseTestCase): placeholder=' [truncated]...') self.check_wrap(self.text, 80, [self.text], placeholder='.' * 1000) + def test_placeholder_backtrack(self): + # Test special case when max_lines insufficient, but what + # would be last wrapped line so long the placeholder cannot + # be added there without violence. So, textwrap backtracks, + # adding placeholder to the penultimate line. + text = 'Good grief Python features are advancing quickly!' + self.check_wrap(text, 12, + ['Good grief', 'Python*****'], + max_lines=3, + placeholder='*****') + class LongWordTestCase (BaseTestCase): def setUp(self):