From: R David Murray Date: Mon, 16 Jul 2012 00:12:24 +0000 (-0400) Subject: #4640: Add optparse tests for '-xxx' invalid when defining options. X-Git-Tag: v3.3.0b2~193 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6159e0956c812d66b3e8fd8bb37f0d5d1ca9fc40;p=thirdparty%2FPython%2Fcpython.git #4640: Add optparse tests for '-xxx' invalid when defining options. Patch by Aaron (hac.man). --- diff --git a/Lib/test/test_optparse.py b/Lib/test/test_optparse.py index d1ae7574b74f..78de278f76ef 100644 --- a/Lib/test/test_optparse.py +++ b/Lib/test/test_optparse.py @@ -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()