[Python-checkins] cpython: #4640: Add optparse tests for '-xxx' invalid when defining options.

r.david.murray python-checkins at python.org
Mon Jul 16 02:12:52 CEST 2012


http://hg.python.org/cpython/rev/844bb753570f
changeset:   78124:844bb753570f
user:        R David Murray <rdmurray at bitdance.com>
date:        Sun Jul 15 20:12:24 2012 -0400
summary:
  #4640: Add optparse tests for '-xxx' invalid when defining options.

Patch by Aaron (hac.man).

files:
  Lib/test/test_optparse.py |  16 ++++++++++++++++
  1 files changed, 16 insertions(+), 0 deletions(-)


diff --git a/Lib/test/test_optparse.py b/Lib/test/test_optparse.py
--- a/Lib/test/test_optparse.py
+++ b/Lib/test/test_optparse.py
@@ -318,6 +318,22 @@
             ["-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()

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list