]> granicus.if.org Git - python/commitdiff
#4640: Add optparse tests for '-xxx' invalid when defining options.
authorR David Murray <rdmurray@bitdance.com>
Mon, 16 Jul 2012 00:12:24 +0000 (20:12 -0400)
committerR David Murray <rdmurray@bitdance.com>
Mon, 16 Jul 2012 00:12:24 +0000 (20:12 -0400)
Patch by Aaron (hac.man).

Lib/test/test_optparse.py

index d1ae7574b74fc8d85a397a197582c3faa03cf0a3..78de278f76ef524e426b201b60efbe8bab7f0639 100644 (file)
@@ -318,6 +318,22 @@ class TestOptionChecks(BaseTest):
             ["-b"], {'action': 'store',
                      'callback_kwargs': 'foo'})
 
+    def test_no_single_dash(self):
+        self.assertOptionError(
+            "invalid long option string '-debug': "
+            "must start with --, followed by non-dash",
+            ["-debug"])
+
+        self.assertOptionError(
+            "option -d: invalid long option string '-debug': must start with"
+            " --, followed by non-dash",
+            ["-d", "-debug"])
+
+        self.assertOptionError(
+            "invalid long option string '-debug': "
+            "must start with --, followed by non-dash",
+            ["-debug", "--debug"])
+
 class TestOptionParser(BaseTest):
     def setUp(self):
         self.parser = OptionParser()