summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_argparse.py
diff options
context:
space:
mode:
authorSteven Bethard <steven.bethard@gmail.com>2010-11-01 15:57:36 (GMT)
committerSteven Bethard <steven.bethard@gmail.com>2010-11-01 15:57:36 (GMT)
commit1ca45a5292a382d5902b80de5c8274994a985e84 (patch)
treea27a52333253ed1f82246d295fcf3bb69ce0aa32 /Lib/test/test_argparse.py
parent6509599056bb1d4fcd9e071d641715846977de8b (diff)
downloadcpython-1ca45a5292a382d5902b80de5c8274994a985e84.zip
cpython-1ca45a5292a382d5902b80de5c8274994a985e84.tar.gz
cpython-1ca45a5292a382d5902b80de5c8274994a985e84.tar.bz2
Fix bug 9352 where characters were being lost in parsing some short options
Diffstat (limited to 'Lib/test/test_argparse.py')
-rw-r--r--Lib/test/test_argparse.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py
index 358179b..30302e9 100644
--- a/Lib/test/test_argparse.py
+++ b/Lib/test/test_argparse.py
@@ -465,6 +465,30 @@ class TestOptionalsAlternatePrefixCharsAddedHelp(ParserTestCase):
('/ba +f', NS(f=True, bar=None, baz=42))
]
+
+class TestOptionalsAlternatePrefixCharsMultipleShortArgs(ParserTestCase):
+ """Verify that Optionals must be called with their defined prefixes"""
+
+ parser_signature = Sig(prefix_chars='+-', add_help=False)
+ argument_signatures = [
+ Sig('-x', action='store_true'),
+ Sig('+y', action='store_true'),
+ Sig('+z', action='store_true'),
+ ]
+ failures = ['-w',
+ '-xyz',
+ '+x',
+ '-y',
+ '+xyz',
+ ]
+ successes = [
+ ('', NS(x=False, y=False, z=False)),
+ ('-x', NS(x=True, y=False, z=False)),
+ ('+y -x', NS(x=True, y=True, z=False)),
+ ('+yz -x', NS(x=True, y=True, z=True)),
+ ]
+
+
class TestOptionalsShortLong(ParserTestCase):
"""Test a combination of single- and double-dash option strings"""