]> granicus.if.org Git - python/commitdiff
Add test_unix_options() to WrapTestCase to test for SF bug #596434.
authorGreg Ward <gward@python.net>
Thu, 22 Aug 2002 21:10:07 +0000 (21:10 +0000)
committerGreg Ward <gward@python.net>
Thu, 22 Aug 2002 21:10:07 +0000 (21:10 +0000)
Lib/test/test_textwrap.py

index a19e3ba89afff6e44c9f059b14dda5759e74eb45..d6bd47c31b7d34a5c053659a0bec6b01dd7a8fc3 100644 (file)
@@ -163,6 +163,34 @@ What a mess!
                           "\nexpected %r\n"
                           "but got  %r" % (expect, result))
 
+    def test_unix_options (self):
+        # Test that Unix-style command-line options are wrapped correctly.
+        # Both Optik (OptionParser) and Docutils rely on this behaviour!
+
+        text = "You should use the -n option, or --dry-run in its long form."
+        self.check_wrap(text, 20,
+                        ["You should use the",
+                         "-n option, or --dry-",
+                         "run in its long",
+                         "form."])
+        self.check_wrap(text, 21,
+                        ["You should use the -n",
+                         "option, or --dry-run",
+                         "in its long form."])
+        expect = ["You should use the -n option, or",
+                  "--dry-run in its long form."]
+        self.check_wrap(text, 32, expect)
+        self.check_wrap(text, 34, expect)
+        self.check_wrap(text, 35, expect)
+        self.check_wrap(text, 38, expect)
+        expect = ["You should use the -n option, or --dry-",
+                  "run in its long form."]
+        self.check_wrap(text, 39, expect)
+        self.check_wrap(text, 41, expect)
+        expect = ["You should use the -n option, or --dry-run",
+                  "in its long form."]
+        self.check_wrap(text, 42, expect)
+
     def test_split(self):
         # Ensure that the standard _split() method works as advertised
         # in the comments