summaryrefslogtreecommitdiff
path: root/tests/test_argparse.py
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'master' into blackTodd Leonhardt2021-02-191-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | # Conflicts: # cmd2/__init__.py # cmd2/argparse_completer.py # cmd2/argparse_custom.py # cmd2/cmd2.py # cmd2/decorators.py # cmd2/exceptions.py # cmd2/utils.py # examples/arg_decorators.py # examples/argparse_completion.py # examples/modular_commands_main.py # tests/test_argparse_completer.py # tests/test_argparse_custom.py # tests/test_cmd2.py # tests/test_completion.py # tests/test_history.py
| * Removed with_argparser_and_unknown_args since it was deprecated in 1.3.0.Kevin Van Brunt2021-01-221-1/+1
| |
* | Add in isort changesTodd Leonhardt2021-01-311-5/+16
| |
* | Attempt to fix remaining black failuresTodd Leonhardt2021-01-311-1/+8
| |
* | Add black for automatic code formatTodd Leonhardt2021-01-311-13/+6
|/
* Changed isort to force wrapping of imports to reduce merge conflicts from ↵Eric Lin2021-01-221-3/+6
| | | | minor import changes.
* Fixed issue where subcommand added with @as_subcommand_to decorator did not ↵Kevin Van Brunt2020-08-271-9/+37
| | | | | | display help when called with -h/--help. 'add_help=False' no longer has to be passed to parsers used in @as_subcommand_to decorator.
* The functions cmd2 adds to Namespaces (get_statement() and get_handler()) ↵Kevin Van Brunt2020-08-261-3/+2
| | | | | | | are now Cmd2AttributeWrapper objects named cmd2_statement and cmd2_handler. This makes it easy to filter out which attributes in an argparse.Namespace were added by cmd2.
* Fixed RecursionError when printing an argparse.Namespace caused by custom ↵Kevin Van Brunt2020-08-251-0/+23
| | | | | | attribute cmd2 was adding Added get_statement() function to argparse.Namespace which returns __statement__ attribute
* Added tests for invalid subcommandsEric Lin2020-08-201-0/+63
|
* Marked with_arparser_and_unknown_args deprecated and consolidatedEric Lin2020-08-041-3/+3
| | | | implementation as an option to with_argparser instead.
* Added info on semantic versioning and branching strategy to CONTRIBUTING.mdTodd Leonhardt2020-04-241-0/+1
| | | | | | | Also: - Added isort to Pipenv dev - Added setup.cfg to make it easy to run flake8, doc8, and isort directly from the command line without using invoke - Ran isort to sort includes
* Updated _set_parser_prog() so future calls to add_parser() will set the ↵Kevin Van Brunt2020-04-231-1/+8
| | | | | | correct prog value This makes dynamically adding subcommands after the CLI starts easier.
* Fixed issue where subcommand usage text could contain a subcommand alias ↵Kevin Van Brunt2020-04-231-10/+52
| | | | instead of the actual name
* Added unit tests for wrappers passing kwargs to command functionsKevin Van Brunt2020-04-211-5/+32
|
* Removed all instances where a parser's prog attribute was being set since ↵Kevin Van Brunt2019-10-301-1/+1
| | | | this is no longer needed
* Changed all uses of sub-command to subcommandKevin Van Brunt2019-07-191-9/+9
|
* Added unit testsKevin Van Brunt2019-05-151-17/+39
|
* Made run_cmd return out and errKevin Van Brunt2019-03-201-26/+21
|
* Added a shlex.split() wrapper to have a common way of calling it.Kevin Van Brunt2019-03-051-12/+0
| | | | Replaced parse_quoted_string with _get_command_arg_list.
* Merge master into with_argument_list and resolved conflictsTodd Leonhardt2019-03-041-4/+0
|\
| * Removed support for c-style and embedded commentsKevin Van Brunt2019-03-011-4/+0
| |
* | Fix for when with_argument_list is called with preserve_quotes optional argumentTodd Leonhardt2019-03-041-0/+8
|/
* Removed ERROR: text from perror outputKevin Van Brunt2018-12-061-1/+1
|
* Fix flake8 issuesTodd Leonhardt2018-12-061-0/+1
| | | | | | | | | | | | | | | | | | | | | | This commit contains a very large number of trivial changes in order to fix flake8 errors and warnings. Predominantly these are whitespace changes. Additionally, the build for Python 3.7 on TravisCI has been tweaked to fail if there are any flake8 errors using the following commandline: * flake8 . --count --ignore=E252 --max-complexity=31 --max-line-length=127 --show-source --statistics NOTE: In the future the max cyclomatic complexity should be lowered, but some improvements need to be made first. One flake8 error is being ignored entirely: * E252 missing whitespace around parameter equals * ignored because it doesn't correctly deal with default argument values after a type hint A few flake8 errors are being selectively ignored in certain files: * C901 fuction is too complex * ignored in argparse_completer.py because the complex code is an override of argparse complexity * E302 expected 2 blank lines after ... * ignored in all unit test files for convenience * F401 module imported but unused * ignored in cmd2/__init__.py because imports are for convenience of cmd2 developers and backwards compatibility * F821 undefined name * ignored in cmd2 script files which are intended to run only within cmd2 applications via pyscript where "app" and "cmd" are defined
* Using sub-command instead of subcommand where possible to be consistent with ↵Kevin Van Brunt2018-10-051-9/+9
| | | | argparse
* Converted help to argparseKevin Van Brunt2018-09-261-1/+1
|
* Fixed unit testKevin Van Brunt2018-09-251-1/+0
|
* Fixed several hack classes build to simulate file descriptorsTodd Leonhardt2018-09-231-5/+5
| | | | | | | | | Now there is a single class, StdSim in utils.py, which is intended to simulate stdout and stderr file objects. This class replaced the following: - pyscript_bridge.py::CopyStream - transcript.py::OutputTrap - conftest.py::StdOut
* Standardize cmd2 imports in tests and exampleskotfu2018-05-231-1/+1
|
* Moved some argparse tests from test_transcript.py to test_argparse.pykotfu2018-05-031-0/+13
|
* Merge branch 'test_merge' into test_ply_mergeEric Lin2018-05-021-1/+1
|\
| * Removed the expensive imports from cmd2/__init__.pyEric Lin2018-04-251-1/+1
| | | | | | | | | | | | | | Added some shared definitions to cmd2/__init__.py -> maybe there's a better place for these? Figured out how to trick bash into showing argument hints. It's a bit weird. Updated all of the tests and examples to import cmd2 resources from their new location without the automatic imports in cmd2/__init__.py For #369
* | Remove POSIX_SHLEX and STRIP_QUOTES_FOR_NON_POSIXkotfu2018-04-251-14/+0
|/
* Most of the unit tests fixed.kotfu2018-04-161-1/+1
|
* Basic structure for cmd2 as a packagekotfu2018-04-161-1/+1
|
* Revert "Basic structure for cmd2 as a package"kotfu2018-04-161-1/+1
| | | | This reverts commit 4a3d01b679c5db7f6cb670ca981a953eb3b98dc5.
* Basic structure for cmd2 as a packagekotfu2018-04-161-1/+1
| | | | Still have a fair amount of work to do to get this sorted.
* Removed unit test dependency on mockTodd Leonhardt2018-04-151-1/+1
| | | | | mock was a backport of Python's built in unittest.mock and was required for Python 3.2 or earlier - Since we now support Python 3.4+ moving forward we no longer need to make use of the 3rd party mock module
* Reorganized some unit testsKevin Van Brunt2018-03-271-71/+0
|
* Fixing unit testsKevin Van Brunt2018-03-251-17/+11
|
* Fix unit tests on macOS when gnureadline is installedTodd Leonhardt2018-03-211-1/+12
| | | | As similar try/except needed to be added to a couple unit test files to try to import gnureadline as readline and fallback to importing readline.
* Fix unit tests and exampleTodd Leonhardt2018-03-161-4/+11
| | | | | | functools.partialmethod() was added in Python 3.4, so it can't be used in Python 2.7. - Modified the code to skip trying to use it for Python 2.7 - Skip the two unit tests which test its usage on Python 2.7
* Added unit tests and examples for tab completion of subcommandsKevin Van Brunt2018-03-161-5/+79
|
* No longer need to manually specify subcommand names for tab completionKevin Van Brunt2018-03-141-4/+1
|
* help command temporarily redirects sys.stdout and sys.stderr to self.stdout ↵Todd Leonhardt2018-01-221-26/+14
| | | | | | | | for argparse commands In order to make "help" behave more consistently for decorated and undecorated commands, argparse output is temporarily redirected to self.stdout. So doing "help history" is similar to "help load". However, when using the "-h" with argparse commands without using the "help" command, the output from argparse isn't redirected to self.stdout. Fixing this would be rather difficult and would essentially involve creating a pyparsing rule to detect it at the parser level.
* Renamed @with_argument_parser decorator to @with_argparserTodd Leonhardt2018-01-211-6/+6
| | | | | Also: - Reanamed foo and bar subcommand methods to base_foo and base_bar
* Added unit tests for sub-commandsTodd Leonhardt2018-01-201-0/+92
|
* Fixed unit testsTodd Leonhardt2018-01-201-6/+12
| | | | Updated unit tests due to changes in how help is output for commands decorated with an argparse ArgumentParser.
* Simplified a few argparse examples and fixed some incorrect documentationTodd Leonhardt2018-01-171-2/+2
| | | | | | I eliminated a few "narg=1" configurations so that a single str value is returned instead of a List[str]. I also reworded some documentation which was no longer correct after the last commit which made "history command" have the same help text as "command -h" when using one of the two argparse decorators.