diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-08-08 11:24:44 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-08-08 11:24:44 -0400 |
commit | 2769e552c771a0999e87fcaa17803dbed9308e91 (patch) | |
tree | 3bae120ec11abec40f86258ef2412a74c17f0c59 | |
parent | f1c244ec9c2ae3918e61958844695fa8bd9eb147 (diff) | |
download | cmd2-git-2769e552c771a0999e87fcaa17803dbed9308e91.tar.gz |
Do not print traceback warning text if debug is not a settable parameter
-rwxr-xr-x | cmd2/cmd2.py | 2 | ||||
-rwxr-xr-x | tests/test_cmd2.py | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index c0246705..19bdc244 100755 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -689,7 +689,7 @@ class Cmd(cmd.Cmd): if apply_style: final_msg = ansi.style_error(final_msg) - if not self.debug: + if not self.debug and 'debug' in self.settable: warning = "\nTo enable full traceback, run the following command: 'set debug true'" final_msg += ansi.style_warning(warning) diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index 6cab69d6..a856c1d6 100755 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -670,6 +670,17 @@ now: True out, err = run_cmd(base_app, 'edit') assert err[0].startswith('Traceback (most recent call last):') +def test_debug_not_settable(base_app): + # Set debug to False and make it unsettable + base_app.debug = False + del base_app.settable['debug'] + + # Cause an exception + out, err = run_cmd(base_app, 'bad "quote') + + # Since debug is unsettable, the user will not be given the option to enable a full traceback + assert err == ['Invalid syntax: No closing quotation'] + def test_edit_file(base_app, request, monkeypatch): # Set a fake editor just to make sure we have one. We aren't really going to call it due to the mock base_app.editor = 'fooedit' |