summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorsteven.bethard <devnull@localhost>2010-02-28 08:04:33 +0000
committersteven.bethard <devnull@localhost>2010-02-28 08:04:33 +0000
commitf34cf60cfcb22c8929543411c15fe662849e4a6a (patch)
tree547faf1668ffccad95edbb76ab41f1dd6aed70d8 /test
parent22948d838fa22c160682419b4be9be7f421c5e39 (diff)
downloadargparse-f34cf60cfcb22c8929543411c15fe662849e4a6a.tar.gz
Allow single character options, e.g. '-' and '+'.
Diffstat (limited to 'test')
-rw-r--r--test/test_argparse.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/test_argparse.py b/test/test_argparse.py
index 290b5e9..968843c 100644
--- a/test/test_argparse.py
+++ b/test/test_argparse.py
@@ -125,6 +125,7 @@ class NS(object):
class ArgumentParserError(Exception):
def __init__(self, message, stdout=None, stderr=None, error_code=None):
+ Exception.__init__(self, message, stdout, stderr)
self.message = message
self.stdout = stdout
self.stderr = stderr
@@ -1204,6 +1205,25 @@ class TestEmptyAndSpaceContainingArguments(ParserTestCase):
]
+class TestPrefixCharacterOnlyArguments(ParserTestCase):
+
+ parser_signature = Sig(prefix_chars='-+')
+ argument_signatures = [
+ Sig('-', dest='x', nargs='?', const='badger'),
+ Sig('+', dest='y', type=int, default=42),
+ Sig('-+-', dest='z', action='store_true'),
+ ]
+ failures = ['-y', '+ -']
+ successes = [
+ ('', NS(x=None, y=42, z=False)),
+ ('-', NS(x='badger', y=42, z=False)),
+ ('- X', NS(x='X', y=42, z=False)),
+ ('+ -3', NS(x=None, y=-3, z=False)),
+ ('-+-', NS(x=None, y=42, z=True)),
+ ('- ===', NS(x='===', y=42, z=False)),
+ ]
+
+
class TestNargsZeroOrMore(ParserTestCase):
"""Tests specifying an args for an Optional that accepts zero or more"""