diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2019-11-22 21:57:51 -0500 |
---|---|---|
committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2019-11-22 21:57:51 -0500 |
commit | efc9ad1141ecb923a52fa3d9a8f018ae9fae2a8d (patch) | |
tree | 9ecb55a5d03a0b3ca70e8c22a2b37b18193375f0 /tests/test_argparse_custom.py | |
parent | bfca9f9a879b50f1a23c733832bbca93ff6cc243 (diff) | |
parent | 1cad8d92b87a227b331c0e86ddbbee25a6742650 (diff) | |
download | cmd2-git-efc9ad1141ecb923a52fa3d9a8f018ae9fae2a8d.tar.gz |
Merge branch 'master' into pyscript_docs
Diffstat (limited to 'tests/test_argparse_custom.py')
-rw-r--r-- | tests/test_argparse_custom.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/test_argparse_custom.py b/tests/test_argparse_custom.py index 65cbc8da..ce789f8e 100644 --- a/tests/test_argparse_custom.py +++ b/tests/test_argparse_custom.py @@ -242,3 +242,20 @@ def test_apcustom_required_options(): parser = Cmd2ArgumentParser() parser.add_argument('--required_flag', required=True) assert 'required arguments' in parser.format_help() + + +def test_override_parser(): + import importlib + from cmd2 import DEFAULT_ARGUMENT_PARSER + + # The standard parser is Cmd2ArgumentParser + assert DEFAULT_ARGUMENT_PARSER == Cmd2ArgumentParser + + # Set our parser module and force a reload of cmd2 so it loads the module + argparse.cmd2_parser_module = 'examples.custom_parser' + importlib.reload(cmd2) + from cmd2 import DEFAULT_ARGUMENT_PARSER + + # Verify DEFAULT_ARGUMENT_PARSER is now our CustomParser + from examples.custom_parser import CustomParser + assert DEFAULT_ARGUMENT_PARSER == CustomParser |