summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_argparse.py
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2014-10-17 23:58:03 (GMT)
committerR David Murray <rdmurray@bitdance.com>2014-10-17 23:58:03 (GMT)
commitafce02ed38bd846c75593319e1df62de9bf3c627 (patch)
tree113352e68074cfce6911d66fd2924ede5038e535 /Lib/test/test_argparse.py
parentd2ff243b3829d17b0a6a9ac5eab0c522f517f466 (diff)
parent7570cbdc6b394cd89990a9252284c7e4a87bd6f1 (diff)
downloadcpython-afce02ed38bd846c75593319e1df62de9bf3c627.zip
cpython-afce02ed38bd846c75593319e1df62de9bf3c627.tar.gz
cpython-afce02ed38bd846c75593319e1df62de9bf3c627.tar.bz2
Merge: #9351: set_defaults on subparser is no longer ignored if set on parent.
Diffstat (limited to 'Lib/test/test_argparse.py')
-rw-r--r--Lib/test/test_argparse.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py
index 3c12aff..b386ec1 100644
--- a/Lib/test/test_argparse.py
+++ b/Lib/test/test_argparse.py
@@ -2781,6 +2781,13 @@ class TestSetDefaults(TestCase):
parser = ErrorRaisingArgumentParser(parents=[parent])
self.assertEqual(NS(x='foo'), parser.parse_args([]))
+ def test_set_defaults_on_parent_and_subparser(self):
+ parser = argparse.ArgumentParser()
+ xparser = parser.add_subparsers().add_parser('X')
+ parser.set_defaults(foo=1)
+ xparser.set_defaults(foo=2)
+ self.assertEqual(NS(foo=2), parser.parse_args(['X']))
+
def test_set_defaults_same_as_add_argument(self):
parser = ErrorRaisingArgumentParser()
parser.set_defaults(w='W', x='X', y='Y', z='Z')