Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd2/cmd2.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ def pexcept(self, msg: Any, *, end: str = '\n', apply_style: bool = True) -> Non
if apply_style:
final_msg = ansi.style_error(final_msg)

if not self.debug:
if not self.debug and 'debug' in self.settable:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice little ruggedization

warning = "\nTo enable full traceback, run the following command: 'set debug true'"
final_msg += ansi.style_warning(warning)

Expand Down
11 changes: 11 additions & 0 deletions tests/test_cmd2.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,17 @@ def test_base_debug(base_app):
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'
Expand Down