diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2020-06-06 02:31:18 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-06 02:31:18 (GMT) |
commit | d5e7348e4105d1d4a1c5bd1087f61041532ecbf3 (patch) | |
tree | 528622c2cf68d2cb173e0feee91fe661c9add432 /Lib/test/test_argparse.py | |
parent | 15fec5627ac343afd0bfa1e847746071982d5172 (diff) | |
download | cpython-d5e7348e4105d1d4a1c5bd1087f61041532ecbf3.zip cpython-d5e7348e4105d1d4a1c5bd1087f61041532ecbf3.tar.gz cpython-d5e7348e4105d1d4a1c5bd1087f61041532ecbf3.tar.bz2 |
bpo-40862: Raise TypeError when const is given to argparse.BooleanOptionalAction (GH-20623) (GH-20664)
Diffstat (limited to 'Lib/test/test_argparse.py')
-rw-r--r-- | Lib/test/test_argparse.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py index e82a0c3..22cae62 100644 --- a/Lib/test/test_argparse.py +++ b/Lib/test/test_argparse.py @@ -700,6 +700,14 @@ class TestBooleanOptionalAction(ParserTestCase): ('--no-foo --foo', NS(foo=True)), ] + def test_const(self): + # See bpo-40862 + parser = argparse.ArgumentParser() + with self.assertRaises(TypeError) as cm: + parser.add_argument('--foo', const=True, action=argparse.BooleanOptionalAction) + + self.assertIn("got an unexpected keyword argument 'const'", str(cm.exception)) + class TestBooleanOptionalActionRequired(ParserTestCase): """Tests BooleanOptionalAction required""" |