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

Function test_run_script

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

Source from the content-addressed store, hash-verified

355
356
357def test_run_script(base_app, request) -> None:
358 test_dir = os.path.dirname(request.module.__file__)
359 filename = os.path.join(test_dir, "script.txt")
360
361 assert base_app._script_dir == []
362 assert base_app._current_script_dir is None
363
364 # Get output out the script
365 script_out, script_err = run_cmd(base_app, f"run_script {filename}")
366 assert base_app.last_result is True
367
368 assert base_app._script_dir == []
369 assert base_app._current_script_dir is None
370
371 # Now run the commands manually and compare their output to script's
372 with open(filename, encoding="utf-8") as file:
373 script_commands = file.read().splitlines()
374
375 manual_out = []
376 manual_err = []
377 for cmdline in script_commands:
378 out, err = run_cmd(base_app, cmdline)
379 manual_out.extend(out)
380 manual_err.extend(err)
381
382 assert script_out == manual_out
383 assert script_err == manual_err
384
385
386def test_run_script_with_empty_args(base_app) -> None:

Callers

nothing calls this directly

Calls 2

run_cmdFunction · 0.85
readMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…