summaryrefslogtreecommitdiff
path: root/Lib/test/test_argparse.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_argparse.py')
-rw-r--r--Lib/test/test_argparse.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py
index 0994e70e65..93ac0c3b74 100644
--- a/Lib/test/test_argparse.py
+++ b/Lib/test/test_argparse.py
@@ -745,6 +745,25 @@ class TestOptionalsActionAppendWithDefault(ParserTestCase):
]
+class TestConstActionsMissingConstKwarg(ParserTestCase):
+ """Tests that const gets default value of None when not provided"""
+
+ argument_signatures = [
+ Sig('-f', action='append_const'),
+ Sig('--foo', action='append_const'),
+ Sig('-b', action='store_const'),
+ Sig('--bar', action='store_const')
+ ]
+ failures = ['-f v', '--foo=bar', '--foo bar']
+ successes = [
+ ('', NS(f=None, foo=None, b=None, bar=None)),
+ ('-f', NS(f=[None], foo=None, b=None, bar=None)),
+ ('--foo', NS(f=None, foo=[None], b=None, bar=None)),
+ ('-b', NS(f=None, foo=None, b=None, bar=None)),
+ ('--bar', NS(f=None, foo=None, b=None, bar=None)),
+ ]
+
+
class TestOptionalsActionAppendConst(ParserTestCase):
"""Tests the append_const action for an Optional"""