MCPcopy Create free account
hub / github.com/python-cmd2/cmd2 / test_scripts_add_to_history

Function test_scripts_add_to_history

tests/test_cmd2.py:462–480  ·  view source on GitHub ↗
(base_app, request)

Source from the content-addressed store, hash-verified

460
461
462def test_scripts_add_to_history(base_app, request) -> None:
463 test_dir = os.path.dirname(request.module.__file__)
464 filename = os.path.join(test_dir, "scripts", "help.txt")
465 command = f"run_script {filename}"
466
467 # Add to history
468 base_app.scripts_add_to_history = True
469 base_app.history.clear()
470 run_cmd(base_app, command)
471 assert len(base_app.history) == 2
472 assert base_app.history.get(1).raw == command
473 assert base_app.history.get(2).raw == "help -v"
474
475 # Do not add to history
476 base_app.scripts_add_to_history = False
477 base_app.history.clear()
478 run_cmd(base_app, command)
479 assert len(base_app.history) == 1
480 assert base_app.history.get(1).raw == command
481
482
483def test_run_script_nested_run_scripts(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…