Skip to content

Commit 5c6014f

Browse files
committed
Added test.
1 parent 89be528 commit 5c6014f

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

tests/test_cmd2.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,25 @@ def test_set_allow_style(base_app, new_val, is_valid, expected) -> None:
240240
assert out
241241

242242

243+
def test_set_traceback_show_locals(base_app: cmd2.Cmd) -> None:
244+
# Use the set command to alter traceback_show_locals
245+
246+
# Clear any existing value
247+
base_app.traceback_kwargs.pop("show_locals", None)
248+
assert "show_locals" not in base_app.traceback_kwargs
249+
250+
# Test that we receive a default value of False if not present
251+
orig_val = base_app.traceback_show_locals
252+
assert orig_val is False
253+
assert "show_locals" not in base_app.traceback_kwargs
254+
255+
# Test setting it
256+
new_val = not orig_val
257+
run_cmd(base_app, f"set traceback_show_locals {new_val}")
258+
assert base_app.traceback_show_locals is new_val
259+
assert base_app.traceback_kwargs["show_locals"] is new_val
260+
261+
243262
def test_set_with_choices(base_app) -> None:
244263
"""Test choices validation of Settables"""
245264
fake_choices = ["valid", "choices"]

0 commit comments

Comments
 (0)