Skip to content

Commit b3bfe66

Browse files
committed
Add unit test for cmd2.Cmd._completion_supported
1 parent 9753865 commit b3bfe66

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/test_cmd2.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2286,6 +2286,28 @@ def test_get_settable_completion_items(base_app) -> None:
22862286
assert cur_settable.description[0:10] in cur_res.descriptive_data[1]
22872287

22882288

2289+
def test_completion_supported(base_app) -> None:
2290+
# use_rawinput is True and completekey is non-empty -> True
2291+
base_app.use_rawinput = True
2292+
base_app.completekey = 'tab'
2293+
assert base_app._completion_supported() is True
2294+
2295+
# use_rawinput is False and completekey is non-empty -> False
2296+
base_app.use_rawinput = False
2297+
base_app.completekey = 'tab'
2298+
assert base_app._completion_supported() is False
2299+
2300+
# use_rawinput is True and completekey is empty -> False
2301+
base_app.use_rawinput = True
2302+
base_app.completekey = ''
2303+
assert base_app._completion_supported() is False
2304+
2305+
# use_rawinput is False and completekey is empty -> False
2306+
base_app.use_rawinput = False
2307+
base_app.completekey = ''
2308+
assert base_app._completion_supported() is False
2309+
2310+
22892311
def test_alias_no_subcommand(base_app) -> None:
22902312
_out, err = run_cmd(base_app, 'alias')
22912313
assert "Usage: alias [-h]" in err[0]

0 commit comments

Comments
 (0)