summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_textwrap.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_textwrap.py')
-rw-r--r--Lib/test/test_textwrap.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/Lib/test/test_textwrap.py b/Lib/test/test_textwrap.py
index ea7c089..5a33c15 100644
--- a/Lib/test/test_textwrap.py
+++ b/Lib/test/test_textwrap.py
@@ -184,6 +184,16 @@ What a mess!
self.check_wrap(text, 42,
["this-is-a-useful-feature-for-reformatting-",
"posts-from-tim-peters'ly"])
+ # The test tests current behavior but is not testing parts of the API.
+ expect = ("this-|is-|a-|useful-|feature-|for-|"
+ "reformatting-|posts-|from-|tim-|peters'ly").split('|')
+ self.check_wrap(text, 1, expect, break_long_words=False)
+ self.check_split(text, expect)
+
+ self.check_split('e-mail', ['e-mail'])
+ self.check_split('Jelly-O', ['Jelly-O'])
+ # The test tests current behavior but is not testing parts of the API.
+ self.check_split('half-a-crown', 'half-|a-|crown'.split('|'))
def test_hyphenated_numbers(self):
# Test that hyphenated numbers (eg. dates) are not broken like words.
@@ -195,6 +205,7 @@ What a mess!
'released on 1994-02-15.'])
self.check_wrap(text, 40, ['Python 1.0.0 was released on 1994-01-26.',
'Python 1.0.1 was released on 1994-02-15.'])
+ self.check_wrap(text, 1, text.split(), break_long_words=False)
text = "I do all my shopping at 7-11."
self.check_wrap(text, 25, ["I do all my shopping at",
@@ -202,6 +213,7 @@ What a mess!
self.check_wrap(text, 27, ["I do all my shopping at",
"7-11."])
self.check_wrap(text, 29, ["I do all my shopping at 7-11."])
+ self.check_wrap(text, 1, text.split(), break_long_words=False)
def test_em_dash(self):
# Test text with em-dashes
@@ -326,6 +338,10 @@ What a mess!
self.check_split("the ['wibble-wobble'] widget",
['the', ' ', "['wibble-", "wobble']", ' ', 'widget'])
+ # The test tests current behavior but is not testing parts of the API.
+ self.check_split("what-d'you-call-it.",
+ "what-d'you-|call-|it.".split('|'))
+
def test_funky_parens (self):
# Second part of SF bug #596434: long option strings inside
# parentheses.
@@ -428,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!"