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

Function test_scripts_add_to_history

tests/test_run_pyscript.py:98–116  ·  view source on GitHub ↗
(base_app, request)

Source from the content-addressed store, hash-verified

96
97
98def test_scripts_add_to_history(base_app, request) -> None:
99 test_dir = os.path.dirname(request.module.__file__)
100 python_script = os.path.join(test_dir, "pyscript", "help.py")
101 command = f"run_pyscript {python_script}"
102
103 # Add to history
104 base_app.scripts_add_to_history = True
105 base_app.history.clear()
106 run_cmd(base_app, command)
107 assert len(base_app.history) == 2
108 assert base_app.history.get(1).raw == command
109 assert base_app.history.get(2).raw == "help"
110
111 # Do not add to history
112 base_app.scripts_add_to_history = False
113 base_app.history.clear()
114 run_cmd(base_app, command)
115 assert len(base_app.history) == 1
116 assert base_app.history.get(1).raw == command
117
118
119def test_run_pyscript_dir(base_app, request) -> None:

Callers

nothing calls this directly

Calls 3

run_cmdFunction · 0.85
clearMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…