summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_argparse.py
diff options
context:
space:
mode:
authorJack DeVries <58614260+jdevries3133@users.noreply.github.com>2021-07-31 16:27:55 (GMT)
committerGitHub <noreply@github.com>2021-07-31 16:27:55 (GMT)
commit0ad173249d287794d53e6a1fe2d58bb2adee2276 (patch)
tree29c7cf367e7407d308b692a86c202a445c74559f /Lib/test/test_argparse.py
parent1cf8424a62db38a041d421a46618e025bbb87f89 (diff)
downloadcpython-0ad173249d287794d53e6a1fe2d58bb2adee2276.zip
cpython-0ad173249d287794d53e6a1fe2d58bb2adee2276.tar.gz
cpython-0ad173249d287794d53e6a1fe2d58bb2adee2276.tar.bz2
bpo-37880: for argparse add_argument with action='store_const', const now defaults to None. (GH-26707)
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 0994e70..93ac0c3 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"""