summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-10-25 11:46:44 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-10-25 11:46:44 (GMT)
commita6eba11f866f0575e18398d6fdc2cbd47ccb2495 (patch)
treeafcd090aef5186d346ef150824250cbd3e86050d /Lib/test
parentaf4e4747f5e32ec60dbc98fdbeb9681bf3fafe64 (diff)
parentf3ebc9fe3fae3d44da4d0da9764ed7c033115f12 (diff)
downloadcpython-a6eba11f866f0575e18398d6fdc2cbd47ccb2495.zip
cpython-a6eba11f866f0575e18398d6fdc2cbd47ccb2495.tar.gz
cpython-a6eba11f866f0575e18398d6fdc2cbd47ccb2495.tar.bz2
Issue #20491: The textwrap.TextWrapper class now honors non-breaking spaces.
Based on patch by Kaarle Ritvanen.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_textwrap.py31
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!"