mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
Issue #20491: The textwrap.TextWrapper class now honors non-breaking spaces.
Based on patch by Kaarle Ritvanen.
This commit is contained in:
parent
42bababba6
commit
f3ebc9fe3f
3 changed files with 47 additions and 14 deletions
|
@ -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!"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue