]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
SF #965425: add WrapTestCase.test_punct_hyphens() to ensure that
authorGreg Ward <gward@python.net>
Thu, 3 Jun 2004 01:51:27 +0000 (01:51 +0000)
committerGreg Ward <gward@python.net>
Thu, 3 Jun 2004 01:51:27 +0000 (01:51 +0000)
hyphenated words wrapped in punctuation, like "foo-bar" or [ding-dong],
are split correctly.

Lib/test/test_textwrap.py

index 6811119d4caa506e956535a2416eda0fc3ce0cb9..52389e481e6f0d159cdd79d27c866261a8e390a5 100644 (file)
@@ -1,5 +1,5 @@
 #
-# Test script for the textwrap module.
+# Test suite for the textwrap module.
 #
 # Original tests written by Greg Ward <gward@python.net>.
 # Converted to PyUnit by Peter Hansen <peter@engcorp.com>.
@@ -271,6 +271,23 @@ What a mess!
         self.check_split("foo --option-opt bar",
                          ["foo", " ", "--option-", "opt", " ", "bar"])
 
+    def test_punct_hyphens(self):
+        # Oh bother, SF #965425 found another problem with hyphens --
+        # hyphenated words in single quotes weren't handled correctly.
+        # In fact, the bug is that *any* punctuation around a hyphenated
+        # word was handled incorrectly, except for a leading "--", which
+        # was special-cased for Optik and Docutils.  So test a variety
+        # of styles of punctuation around a hyphenated word.
+        # (Actually this is based on an Optik bug report, #813077).
+        self.check_split("the 'wibble-wobble' widget",
+                         ['the', ' ', "'wibble-", "wobble'", ' ', 'widget'])
+        self.check_split('the "wibble-wobble" widget',
+                         ['the', ' ', '"wibble-', 'wobble"', ' ', 'widget'])
+        self.check_split("the (wibble-wobble) widget",
+                         ['the', ' ', "(wibble-", "wobble)", ' ', 'widget'])
+        self.check_split("the ['wibble-wobble'] widget",
+                         ['the', ' ', "['wibble-", "wobble']", ' ', 'widget'])
+
     def test_funky_parens (self):
         # Second part of SF bug #596434: long option strings inside
         # parentheses.