mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
gh-92248: Deprecate type
, choices
, metavar
parameters of argparse.BooleanOptionalAction
(#103678)
Co-authored-by: Kirill <80244920+Eclips4@users.noreply.github.com> Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com> Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
This commit is contained in:
parent
ac56a854b4
commit
27a7d5e1cd
4 changed files with 74 additions and 3 deletions
|
@ -765,6 +765,49 @@ class TestBooleanOptionalAction(ParserTestCase):
|
|||
|
||||
self.assertIn("got an unexpected keyword argument 'const'", str(cm.exception))
|
||||
|
||||
def test_deprecated_init_kw(self):
|
||||
# See gh-92248
|
||||
parser = argparse.ArgumentParser()
|
||||
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
parser.add_argument(
|
||||
'-a',
|
||||
action=argparse.BooleanOptionalAction,
|
||||
type=None,
|
||||
)
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
parser.add_argument(
|
||||
'-b',
|
||||
action=argparse.BooleanOptionalAction,
|
||||
type=bool,
|
||||
)
|
||||
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
parser.add_argument(
|
||||
'-c',
|
||||
action=argparse.BooleanOptionalAction,
|
||||
metavar=None,
|
||||
)
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
parser.add_argument(
|
||||
'-d',
|
||||
action=argparse.BooleanOptionalAction,
|
||||
metavar='d',
|
||||
)
|
||||
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
parser.add_argument(
|
||||
'-e',
|
||||
action=argparse.BooleanOptionalAction,
|
||||
choices=None,
|
||||
)
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
parser.add_argument(
|
||||
'-f',
|
||||
action=argparse.BooleanOptionalAction,
|
||||
choices=(),
|
||||
)
|
||||
|
||||
class TestBooleanOptionalActionRequired(ParserTestCase):
|
||||
"""Tests BooleanOptionalAction required"""
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue