summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_argparse.py
Commit message (Collapse)AuthorAgeFilesLines
* gh-101979: argparse: fix a bug where parentheses in metavar argument of ↵Miss Islington (bot)2023-03-051-0/+22
| | | | | | | add_argument() were dropped (GH-102318) (cherry picked from commit 9a478be1a4314734c697dda7a7b0e633a6fb0751) Co-authored-by: Yeojin Kim <yeojin.dev@gmail.com>
* gh-80448: argparse: Fix IndexError on store_true action (GH-15656)Miss Islington (bot)2022-11-121-1/+1
| | | | | | | | (cherry picked from commit e02cc6d42aee1f0a9ee629f76576eee478224d9d) Co-authored-by: Hai Shi <shihai1992@gmail.com> Co-authored-by: Rémi Lapeyre <remi.lapeyre@henki.fr> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
* gh-91832: Add 'required' attr to argparse.Action repr (GH-91841)Miss Islington (bot)2022-04-281-2/+4
| | | | | | | | | | | | GH- Adding 'required' to names in Lib.argparse.Action gh-91832: Added 'required' to the list `names` in `Lib.argparse.Action`. Changed constant strings that test the Action object. Automerge-Triggered-By: GH:merwok (cherry picked from commit 4ed3900041c688a02dca1eb3323083d720dd0d93) Co-authored-by: Abhigyan Bose <abhigyandeepbose@gmail.com>
* bpo-14156: Make argparse.FileType work correctly for binary file modes when ↵Miss Islington (bot)2022-03-061-13/+102
| | | | | | | | | argument is '-' (GH-13165) Also made modes containing 'a' or 'x' act the same as a mode containing 'w' when argument is '-' (so 'a'/'x' return sys.stdout like 'w', and 'ab'/'xb' return sys.stdout.buffer like 'wb'). (cherry picked from commit eafec26ae5327bb23b6dace2650b074c3327dfa0) Co-authored-by: MojoVampire <shadowranger+github@gmail.com>
* bpo-46080: fix argparse help generation exception in edge case (GH-30111)Miss Islington (bot)2022-01-201-2/+5
| | | | | | | | Fix an uncaught exception during help text generation when argparse.BooleanOptionalAction is used with default=argparse.SUPPRESS and help is specified. (cherry picked from commit 9e87c0e03fa501fb90008547983ce4c1dcaaf90c) Co-authored-by: Felix Fontein <felix@fontein.de>
* bpo-46411: Remove unnecessary calls to sys.exc_info() in tests (GH-30638)Miss Islington (bot)2022-01-181-6/+4
| | | | | (cherry picked from commit a287b31bcb065e4122400cb59167340d25480e6d) Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
* bpo-26952: [argparse] clearer error when formatting an empty mutually… ↵Miss Islington (bot)2021-12-151-0/+7
| | | | | | | (GH-30099) (GH-30114) (cherry picked from commit 86de99588db3beff964137f4fe27dd1077a09b35) Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
* bpo-45235: Revert an argparse bugfix that caused a regression (GH-29525) ↵Miss Islington (bot)2021-11-121-6/+0
| | | | (GH-29530)
* bpo-24444: fix an error in argparse help when help for an option is blank ↵Miss Islington (bot)2021-10-131-0/+36
| | | | | | | (GH-28050) (GH-28931) (cherry picked from commit 6fafc25aea8689048314b5bf7a9bb986bb1ce238) Co-authored-by: andrei kulakov <andrei.avk@gmail.com>
* [3.10] bpo-45229: Remove test_main in many tests (GH-28405) (GH-28455)Serhiy Storchaka2021-09-191-5/+2
| | | | | | | | | | | Instead of explicitly enumerate test classes for run_unittest() use the unittest ability to discover tests. This also makes these tests discoverable and runnable with unittest. load_tests() can be used for dynamic generating tests and adding doctests. setUpModule(), tearDownModule() and addModuleCleanup() can be used for running code before and after all module tests. (cherry picked from commit 40348acc180580371d25f75f46b27048e35f2435)
* bpo-45235: Fix argparse overrides namespace with subparser defaults ↵Miss Islington (bot)2021-09-181-0/+6
| | | | (GH-28420) (GH-28442)
* bpo-38956: don't print BooleanOptionalAction's default twice (GH-27672)Miss Islington (bot)2021-08-171-7/+14
| | | | | | Co-authored-by: Micky Yun Chan <michan@redhat.com> (cherry picked from commit 1512bc21d60f098a9e9f37b44a2f6a9b49a3fd4f) Co-authored-by: Maximilian Hils <git@maximilianhils.com>
* bpo-29298: Fix crash with required subparsers without dest (GH-3680) (GH-27303)Miss Islington (bot)2021-07-231-0/+24
| | | | | (cherry picked from commit 17575f73ce2cb9f3a4eb4cc416c690f9a4e7205c) Co-authored-by: Anthony Sottile <asottile@umich.edu>
* bpo-43651: PEP 597: Fix EncodingWarning in some tests (GH-25142)Inada Naoki2021-04-021-6/+8
| | | | | | | | | | | | | * test__xxsubinterpreters * test_builtin * test_doctest * test_exceptions * test_opcodes * test_support * test_argparse * test_baseexception * test_bdb * test_bool * test_asdl_parser
* bpo-9694: Fix misleading phrase "optional arguments" (GH-23858)Raymond Hettinger2020-12-231-56/+56
|
* bpo-40275: Use new test.support helper submodules in tests (GH-21448)Hai Shi2020-08-031-2/+3
|
* bpo-40862: Raise TypeError when const is given to ↵Rémi Lapeyre2020-06-051-0/+8
| | | | argparse.BooleanOptionalAction (GH-20623)
* bpo-39058: Preserve attribute order in argparse Namespace reprs. (GH-17621)Raymond Hettinger2020-05-181-1/+1
|
* bpo-9495: avoid confusing chained exception in argparse test (GH-17120)alclarks2020-02-211-1/+2
|
* bpo-39546: argparse: Honor allow_abbrev=False for specified prefix_chars ↵Kyle Meyer2020-02-181-0/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | (GH-18337) When `allow_abbrev` was first added, disabling the abbreviation of long options broke the grouping of short flags ([bpo-26967](https://bugs.python.org/issue26967)). As a fix, b1e4d1b603 (contained in v3.8) ignores `allow_abbrev=False` for a given argument string if the string does _not_ start with "--" (i.e. it doesn't look like a long option). This fix, however, doesn't take into account that long options can start with alternative characters specified via `prefix_chars`, introducing a regression: `allow_abbrev=False` has no effect on long options that start with an alternative prefix character. The most minimal fix would be to replace the "starts with --" check with a "starts with two prefix_chars characters". But `_get_option_tuples` already distinguishes between long and short options, so let's instead piggyback off of that check by moving the `allow_abbrev` condition into `_get_option_tuples`. https://bugs.python.org/issue39546
* bpo-38438: Simplify argparse "star nargs" usage. (GH-17106)Brandt Bucher2019-11-111-7/+7
|
* bpo-8538: Add support for boolean actions to argparse (GH-11478)Rémi Lapeyre2019-09-131-11/+45
| | | Co-Authored-By: remilapeyre <remi.lapeyre@henki.fr>
* bpo-9938: Add optional keyword argument exit_on_error to ↵Hai Shi2019-09-121-0/+15
| | | | | | | | | | | | argparse.ArgumentParser (GH-15362) Co-Authored-by: Xuanji Li <xuanji@gmail.com> https://bugs.python.org/issue9938 Automerge-Triggered-By: @matrixise
* bpo-29553: Fix ArgumentParser.format_usage() for mutually exclusive groups ↵Flavian Hautbois2019-08-251-0/+40
| | | | | (GH-14976) Co-authored-by: Andrew Nester <andrew.nester.dev@gmail.com>
* bpo-16970: Adding error message for invalid args (GH-14844)tmblweed2019-08-021-1/+29
| | | | | | | | BPO -16970: Adding error message for invalid args Applied the patch argparse-v2 patch issue 16970, ran patch check and the test suite, test_argparse with 0 errors https://bugs.python.org/issue16970
* bpo-26967: fix flag grouping with allow_abbrev=False (GH-14316)Zac Hatfield-Dodds2019-07-141-0/+19
| | | | | | | | | | | The `allow_abbrev` option for ArgumentParser is documented and intended to disable support for unique prefixes of --options, which may sometimes be ambiguous due to deferred parsing. However, the initial implementation also broke parsing of grouped short flags, such as `-ab` meaning `-a -b` (or `-a=b`). Checking the argument for a leading `--` before rejecting it fixes this. This was prompted by pytest-dev/pytest#5469, so a backport to at least 3.8 would be great :smile: And this is my first PR to CPython, so please let me know if I've missed anything! https://bugs.python.org/issue26967
* Remove unused imports in tests (GH-14518)Victor Stinner2019-07-011-1/+0
|
* bpo-37150: Throw ValueError if FileType class object was passed in ↵zygocephalus2019-06-071-0/+18
| | | | | | | | | | | | | | add_argument (GH-13805) There is a possibility that someone (like me) accidentally will omit parentheses with `FileType` arguments after `FileType`, and parser will contain wrong file until someone will try to use it. Example: ```python parser = argparse.ArgumentParser() parser.add_argument('-x', type=argparse.FileType) ``` https://bugs.python.org/issue37150
* bpo-23378: Add an extend action to argparse (GH-13305)Batuhan Taşkaya2019-05-211-0/+9
| | | | | | Add an extend action to argparse https://bugs.python.org/issue23378
* bpo-22831: Use "with" to avoid possible fd leaks in tests (part 2). (GH-10929)Serhiy Storchaka2019-03-051-12/+8
|
* bpo-34582: Adds JUnit XML output for regression tests (GH-9210)Steve Dower2018-09-181-4/+14
|
* bpo-13041: Use shutil.get_terminal_size() in argparse.HelpFormatter (GH-8459)Berker Peksag2018-07-251-2/+3
|
* bpo-11874: fix assertion failure in argparse metavar handling (GH-1826)wim glenn2018-06-081-9/+33
| | | | | | - bugfix and test for fragile metavar handling in argparse (see bpo-24089, bpo-14046, bpo-25058, bpo-11874) - also fixes some incorrect tests that did not make 1-element tuples correctly
* bpo-33109: argparse subparsers are once again not required by default (GH-6919)Ned Deily2018-05-241-1/+3
| | | | | | | | | bpo-26510 in 3.7.0a2 changed the behavior of argparse to make subparsers required by default, returning to the behavior of 2.7 and 3.2. The behavior was changed in 3.3 to be no longer required. While it might make more sense to have the default to required, compatibility with 3.3 through 3.6 is probably less disruptive than trying to reintroduce compatibility with 2.7 at this point. This change restores the 3.6 behavior.
* bpo-26510: make argparse subparsers required by default (#3027)Anthony Sottile2017-09-201-1/+36
| | | | | | This fixes a regression from Python 2. To get optional subparsers, use the new parameter ``add_subparsers(required=False)``. Patch by Anthony Sottile.
* bpo-14191 Add parse_intermixed_args. (#3319)R. David Murray2017-09-071-0/+87
| | | This adds support for parsing a command line where options and positionals are intermixed as is common in many unix commands. This is paul.j3's patch with a few tweaks.
* bpo-29783: Replace codecs.open() with io.open() (#599)Victor Stinner2017-06-161-1/+1
|
* Issue #29290: Merge 3.5.Xiang Zhang2017-01-221-0/+17
|\
| * Issue #29290: argparse help messages won't wrap at non-breaking spaces.Xiang Zhang2017-01-221-0/+17
| |
* | Issue #28300: Merge from 3.5Berker Peksag2016-09-281-1/+1
|\ \ | |/
| * Issue #28300: Fix typos, patch by Shlomi FishBerker Peksag2016-09-281-1/+1
| |
* | Issue #12713: reverted fix pending further discussion.Vinay Sajip2016-08-231-65/+27
| |
* | Closes #12713: Allowed abbreviation of subcommands in argparse.Vinay Sajip2016-08-181-27/+65
| |
* | Merge typo fixes from 3.5Martin Panter2016-04-051-5/+5
|\ \ | |/
| * Fix typos in documentation and commentsMartin Panter2016-04-051-5/+5
| |
* | Merge typo and grammar fixes from 3.5Martin Panter2015-11-141-1/+1
|\ \ | |/
| * Merge typo and grammar fixes from 3.4 into 3.5Martin Panter2015-11-141-1/+1
| |\
| | * Fix a few grammar problems in the documentation and commentsMartin Panter2015-11-141-1/+1
| | |
* | | Issue #24360: Improve __repr__ of argparse.Namespace() for invalid identifiers.Berker Peksag2015-07-291-0/+15
|/ / | | | | | | Patch by Matthias Bussonnier.
* | Issue #23062: Add a test for suppressing --version with argparse.SUPPRESS.Berker Peksag2015-04-101-28/+26
|\ \ | |/ | | | | TestHelpVersionOptional was redundant.