diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-10-25 11:44:54 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-10-25 11:44:54 (GMT) |
commit | f3ebc9fe3fae3d44da4d0da9764ed7c033115f12 (patch) | |
tree | 29214aa4fce9cf570c160441a43de526f7457eb5 /Lib/test/test_textwrap.py | |
parent | 42bababba62023383291c7413a5d453374ecd933 (diff) | |
download | cpython-f3ebc9fe3fae3d44da4d0da9764ed7c033115f12.zip cpython-f3ebc9fe3fae3d44da4d0da9764ed7c033115f12.tar.gz cpython-f3ebc9fe3fae3d44da4d0da9764ed7c033115f12.tar.bz2 |
Issue #20491: The textwrap.TextWrapper class now honors non-breaking spaces.
Based on patch by Kaarle Ritvanen.
Diffstat (limited to 'Lib/test/test_textwrap.py')
-rw-r--r-- | Lib/test/test_textwrap.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/Lib/test/test_textwrap.py b/Lib/test/test_textwrap.py index a44184f..5a33c15 100644 --- a/Lib/test/test_textwrap.py +++ b/Lib/test/test_textwrap.py @@ -444,6 +444,37 @@ What a mess! text = "aa \xe4\xe4-\xe4\xe4" self.check_wrap(text, 7, ["aa \xe4\xe4-", "\xe4\xe4"]) + def test_non_breaking_space(self): + text = 'This is a sentence with non-breaking\N{NO-BREAK SPACE}space.' + + self.check_wrap(text, 20, + ['This is a sentence', + 'with non-', + 'breaking\N{NO-BREAK SPACE}space.'], + break_on_hyphens=True) + + self.check_wrap(text, 20, + ['This is a sentence', + 'with', + 'non-breaking\N{NO-BREAK SPACE}space.'], + break_on_hyphens=False) + + def test_narrow_non_breaking_space(self): + text = ('This is a sentence with non-breaking' + '\N{NARROW NO-BREAK SPACE}space.') + + self.check_wrap(text, 20, + ['This is a sentence', + 'with non-', + 'breaking\N{NARROW NO-BREAK SPACE}space.'], + break_on_hyphens=True) + + self.check_wrap(text, 20, + ['This is a sentence', + 'with', + 'non-breaking\N{NARROW NO-BREAK SPACE}space.'], + break_on_hyphens=False) + class MaxLinesTestCase(BaseTestCase): text = "Hello there, how are you this fine day? I'm glad to hear it!" |