8000 bpo-30591: Added test for textwrap backtracking. (#1988) · python/cpython@5edf827 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5edf827

Browse files
jonathaneuniceserhiy-storchaka
authored andcommitted
bpo-30591: Added test for textwrap backtracking. (#1988)
1 parent 6f46683 commit 5edf827

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Lib/test/test_textwrap.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,17 @@ def test_placeholder(self):
559559
placeholder=' [truncated]...')
560560
self.check_wrap(self.text, 80, [self.text], placeholder='.' * 1000)
561561

562+
def test_placeholder_backtrack(self):
563+
# Test special case when max_lines insufficient, but what
564+
# would be last wrapped line so long the placeholder cannot
565+
# be added there without violence. So, textwrap backtracks,
566+
# adding placeholder to the penultimate line.
567+
text = 'Good grief Python features are advancing quickly!'
568+
self.check_wrap(text, 12,
569+
['Good grief', 'Python*****'],
570+
max_lines=3,
571+
placeholder='*****')
572+
562573

563574
class LongWordTestCase (BaseTestCase):
564575
def setUp(self):

0 commit comments

Comments
 (0)
0