diff options
author | Jonathan Eunice <jonathan.eunice@gmail.com> | 2017-06-07 20:49:13 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2017-06-07 20:49:13 (GMT) |
commit | 5edf827c8052958b9d293f75ce8d93b66c1d58da (patch) | |
tree | 1eb5dee77e36eeaa1ace3a0d9626aa3af906a3ae | |
parent | 6f46683a6257f22f25d136ed080d58d0c060a43b (diff) | |
download | cpython-5edf827c8052958b9d293f75ce8d93b66c1d58da.zip cpython-5edf827c8052958b9d293f75ce8d93b66c1d58da.tar.gz cpython-5edf827c8052958b9d293f75ce8d93b66c1d58da.tar.bz2 |
bpo-30591: Added test for textwrap backtracking. (#1988)
-rw-r--r-- | Lib/test/test_textwrap.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_textwrap.py b/Lib/test/test_textwrap.py index 5a33c15..47d97bd 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): |