MCPcopy Index your code
hub / github.com/python-cmd2/cmd2 / test_static_subcommands

Function test_static_subcommands

tests/test_commandset.py:763–783  ·  view source on GitHub ↗
(static_subcommands_app)

Source from the content-addressed store, hash-verified

761
762
763def test_static_subcommands(static_subcommands_app) -> None:
764 cmds_cats, _help_topics = static_subcommands_app._build_command_info()
765 assert "Fruits" in cmds_cats
766
767 text = ""
768 line = f"cut {text}"
769 endidx = len(line)
770 begidx = endidx
771 completions = static_subcommands_app.complete(text, line, begidx, endidx)
772
773 # check that the alias shows up correctly
774 assert completions.to_strings() == Completions.from_values(["banana", "bananer", "bokchoy"]).to_strings()
775
776 text = ""
777 line = f"cut bokchoy {text}"
778 endidx = len(line)
779 begidx = endidx
780 completions = static_subcommands_app.complete(text, line, begidx, endidx)
781
782 # verify that argparse completer in commandset functions correctly
783 assert completions.to_strings() == Completions.from_values(["diced", "quartered"]).to_strings()
784
785
786complete_states_expected_self = None

Callers

nothing calls this directly

Calls 4

_build_command_infoMethod · 0.80
to_stringsMethod · 0.80
from_valuesMethod · 0.80
completeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…