summaryrefslogtreecommitdiff
path: root/tests/test_argparse_custom.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_argparse_custom.py')
-rw-r--r--tests/test_argparse_custom.py17
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