Skip to content

Commit 02246d2

Browse files
committed
gh-110131: Drop the test, show a non-empty default in the example
1 parent 5f7766c commit 02246d2

2 files changed

Lines changed: 5 additions & 15 deletions

File tree

‎Doc/library/argparse.rst‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,11 @@ how the command-line arguments should be handled. The supplied actions are:
827827
>>> parser.add_argument("--foo", action="extend", nargs="+", type=str)
828828
>>> parser.parse_args(["--foo", "f1", "--foo", "f2", "f3", "f4"])
829829
Namespace(foo=['f1', 'f2', 'f3', 'f4'])
830+
>>> parser = argparse.ArgumentParser()
831+
>>> parser.add_argument("--foo", action="extend", nargs="+", type=str,
832+
... default=["d1"])
833+
>>> parser.parse_args(["--foo", "f1", "f2"])
834+
Namespace(foo=['d1', 'f1', 'f2'])
830835

831836
.. versionadded:: 3.8
832837

‎Lib/test/test_argparse.py‎

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2470,21 +2470,6 @@ class TestActionExtend(ParserTestCase):
24702470
]
24712471

24722472

2473-
class TestActionExtendWithDefault(ParserTestCase):
2474-
"""Tests the extend action for an Optional with a non-empty default"""
2475-
2476-
argument_signatures = [
2477-
Sig('--baz', action='extend', nargs='+', default=['X']),
2478-
]
2479-
failures = ['a', '--baz', 'a --baz']
2480-
successes = [
2481-
('', NS(baz=['X'])),
2482-
('--baz a', NS(baz=['X', 'a'])),
2483-
('--baz a b', NS(baz=['X', 'a', 'b'])),
2484-
('--baz a --baz b c', NS(baz=['X', 'a', 'b', 'c'])),
2485-
]
2486-
2487-
24882473
class TestNegativeNumber(ParserTestCase):
24892474
"""Test parsing negative numbers"""
24902475

0 commit comments

Comments
 (0)