diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2021-09-18 06:47:41 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-18 06:47:41 (GMT) |
commit | a18d52269ab6071a605d6c72f6af585a4c533ca4 (patch) | |
tree | 393c76cfccc6d274491be71a22068477e8cbd8c5 /Lib/test/test_argparse.py | |
parent | 6e151ff6fc39cc61e57c72a8c00633948c53eec7 (diff) | |
download | cpython-a18d52269ab6071a605d6c72f6af585a4c533ca4.zip cpython-a18d52269ab6071a605d6c72f6af585a4c533ca4.tar.gz cpython-a18d52269ab6071a605d6c72f6af585a4c533ca4.tar.bz2 |
bpo-45235: Fix argparse overrides namespace with subparser defaults (GH-28420) (GH-28443)
Diffstat (limited to 'Lib/test/test_argparse.py')
-rw-r--r-- | Lib/test/test_argparse.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py index 5d8bc14..ab5f35f 100644 --- a/Lib/test/test_argparse.py +++ b/Lib/test/test_argparse.py @@ -3057,6 +3057,12 @@ class TestSetDefaults(TestCase): xparser.set_defaults(foo=2) self.assertEqual(NS(foo=2), parser.parse_args(['X'])) + def test_set_defaults_on_subparser_with_namespace(self): + parser = argparse.ArgumentParser() + xparser = parser.add_subparsers().add_parser('X') + xparser.set_defaults(foo=1) + self.assertEqual(NS(foo=2), parser.parse_args(['X'], NS(foo=2))) + def test_set_defaults_same_as_add_argument(self): parser = ErrorRaisingArgumentParser() parser.set_defaults(w='W', x='X', y='Y', z='Z') |