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))
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):
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