summaryrefslogtreecommitdiff
path: root/test/test_argparse.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_argparse.py')
-rw-r--r--test/test_argparse.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/test_argparse.py b/test/test_argparse.py
index f5906a0..6609e3c 100644
--- a/test/test_argparse.py
+++ b/test/test_argparse.py
@@ -632,6 +632,18 @@ class TestOptionalsActionAppend(ParserTestCase):
]
+class TestOptionalsActionAppendWithDefault(ParserTestCase):
+ """Tests the append action for an Optional"""
+
+ argument_signatures = [Sig('--baz', action='append', default=['X'])]
+ failures = ['a', '--baz', 'a --baz', '--baz a b']
+ successes = [
+ ('', NS(baz=['X'])),
+ ('--baz a', NS(baz=['X', 'a'])),
+ ('--baz a --baz b', NS(baz=['X', 'a', 'b'])),
+ ]
+
+
class TestOptionalsActionAppendConst(ParserTestCase):
"""Tests the append_const action for an Optional"""
@@ -647,6 +659,21 @@ class TestOptionalsActionAppendConst(ParserTestCase):
]
+class TestOptionalsActionAppendConstWithDefault(ParserTestCase):
+ """Tests the append_const action for an Optional"""
+
+ argument_signatures = [
+ Sig('-b', action='append_const', const=Exception, default=['X']),
+ Sig('-c', action='append', dest='b'),
+ ]
+ failures = ['a', '-c', 'a -c', '-bx', '-b x']
+ successes = [
+ ('', NS(b=['X'])),
+ ('-b', NS(b=['X', Exception])),
+ ('-b -cx -b -cyz', NS(b=['X', Exception, 'x', Exception, 'yz'])),
+ ]
+
+
class TestOptionalsActionCount(ParserTestCase):
"""Tests the count action for an Optional"""