mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-37880: for argparse add_argument with action='store_const', const now defaults to None. (GH-26707)
This commit is contained in:
parent
1cf8424a62
commit
0ad173249d
4 changed files with 41 additions and 13 deletions
|
@ -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"""
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue