summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_textwrap.py
diff options
context:
space:
mode:
authorGreg Ward <gward@python.net>2002-10-31 16:11:18 (GMT)
committerGreg Ward <gward@python.net>2002-10-31 16:11:18 (GMT)
commitd1a72a0d5e14d04ea83f154e5ed23202d311db46 (patch)
tree9b1490854fc3a0a4adca11c46de312e7a2be5458 /Lib/test/test_textwrap.py
parent05c93356590c29ac93d4fe903edb5916203cecc5 (diff)
downloadcpython-d1a72a0d5e14d04ea83f154e5ed23202d311db46.zip
cpython-d1a72a0d5e14d04ea83f154e5ed23202d311db46.tar.gz
cpython-d1a72a0d5e14d04ea83f154e5ed23202d311db46.tar.bz2
Ad test_funky_hyphens() to test some screwy edge cases reported in SF
bug #596434. (Alas, I don't think this completely covers that bug.) Remove 'wrapper' argument from BaseTestCase.check_split() -- it's not actually needed.
Diffstat (limited to 'Lib/test/test_textwrap.py')
-rw-r--r--Lib/test/test_textwrap.py23
1 files changed, 18 insertions, 5 deletions
diff --git a/Lib/test/test_textwrap.py b/Lib/test/test_textwrap.py
index 2a6d67a..4a98972 100644
--- a/Lib/test/test_textwrap.py
+++ b/Lib/test/test_textwrap.py
@@ -37,8 +37,8 @@ class BaseTestCase(unittest.TestCase):
result = wrap(text, width, **kwargs)
self.check(result, expect)
- def check_split(self, wrapper, text, expect):
- result = wrapper._split(text)
+ def check_split(self, text, expect):
+ result = self.wrapper._split(text)
self.assertEquals(result, expect,
"\nexpected %r\n"
"but got %r" % (expect, result))
@@ -174,12 +174,12 @@ What a mess!
expect = ["Here's", " ", "an", " ", "--", " ", "em-", "dash", " ",
"and", "--", "here's", " ", "another", "---",
"and", " ", "another!"]
- self.check_split(self.wrapper, text, expect)
+ self.check_split(text, expect)
text = "and then--bam!--he was gone"
expect = ["and", " ", "then", "--", "bam!", "--",
"he", " ", "was", " ", "gone"]
- self.check_split(self.wrapper, text, expect)
+ self.check_split(text, expect)
def test_unix_options (self):
@@ -214,7 +214,20 @@ What a mess!
text = "the -n option, or --dry-run or --dryrun"
expect = ["the", " ", "-n", " ", "option,", " ", "or", " ",
"--dry-", "run", " ", "or", " ", "--dryrun"]
- self.check_split(self.wrapper, text, expect)
+ self.check_split(text, expect)
+
+ def test_funky_hyphens (self):
+ # Screwy edge cases cooked up by David Goodger. All reported
+ # in SF bug #596434.
+ self.check_split("what the--hey!", ["what", " ", "the", "--", "hey!"])
+ self.check_split("what the--", ["what", " ", "the--"])
+ self.check_split("what the--.", ["what", " ", "the--."])
+ self.check_split("--text--.", ["--text--."])
+
+ # I think David got this wrong in the bug report, but it can't
+ # hurt to make sure it stays right!
+ self.check_split("--option", ["--option"])
+ self.check_split("--option-opt", ["--option-", "opt"])
def test_split(self):
# Ensure that the standard _split() method works as advertised