summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_argparse.py
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2012-09-12 01:06:29 (GMT)
committerBarry Warsaw <barry@python.org>2012-09-12 01:06:29 (GMT)
commit03fcfbef0aa9a0990d5cd3995defa8cd089f704c (patch)
tree056171792f9a71cc200050f7c8e90b9f68332d96 /Lib/test/test_argparse.py
parenta8a5b397c1a30568be1309ed265b696da84eeca0 (diff)
downloadcpython-03fcfbef0aa9a0990d5cd3995defa8cd089f704c.zip
cpython-03fcfbef0aa9a0990d5cd3995defa8cd089f704c.tar.gz
cpython-03fcfbef0aa9a0990d5cd3995defa8cd089f704c.tar.bz2
- Issue #15906: Fix a regression in argparse caused by the preceding change,
when action='append', type='str' and default=[].
Diffstat (limited to 'Lib/test/test_argparse.py')
-rw-r--r--Lib/test/test_argparse.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py
index 99c1bab..c611944 100644
--- a/Lib/test/test_argparse.py
+++ b/Lib/test/test_argparse.py
@@ -4480,6 +4480,16 @@ class TestTypeFunctionCallWithNonStringDefault(TestCase):
args = parser.parse_args([])
self.assertEqual(NS(foo='foo_converted'), args)
+ def test_issue_15906(self):
+ # Issue #15906: When action='append', type=str, default=[] are
+ # providing, the dest value was the string representation "[]" when it
+ # should have been an empty list.
+ parser = argparse.ArgumentParser()
+ parser.add_argument('--test', dest='test', type=str,
+ default=[], action='append')
+ args = parser.parse_args([])
+ self.assertEqual(args.test, [])
+
# ======================
# parse_known_args tests
# ======================