]> granicus.if.org Git - python/commitdiff
Ad test_funky_hyphens() to test some screwy edge cases reported in SF
authorGreg Ward <gward@python.net>
Thu, 31 Oct 2002 16:11:18 +0000 (16:11 +0000)
committerGreg Ward <gward@python.net>
Thu, 31 Oct 2002 16:11:18 +0000 (16:11 +0000)
bug #596434.  (Alas, I don't think this completely covers that bug.)

Remove 'wrapper' argument from BaseTestCase.check_split() -- it's not
actually needed.

Lib/test/test_textwrap.py

index 2a6d67a50d1a908686ba9ba0a293666a5c90b43e..4a98972fc064aa13f94e3ae3f98c9d66c69eef4f 100644 (file)
@@ -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