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

Function test_relative_run_script

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

Source from the content-addressed store, hash-verified

547
548
549def test_relative_run_script(base_app, request) -> None:
550 test_dir = os.path.dirname(request.module.__file__)
551 filename = os.path.join(test_dir, "script.txt")
552
553 assert base_app._script_dir == []
554 assert base_app._current_script_dir is None
555
556 # Get output out the script
557 script_out, script_err = run_cmd(base_app, f"_relative_run_script {filename}")
558 assert base_app.last_result is True
559
560 assert base_app._script_dir == []
561 assert base_app._current_script_dir is None
562
563 # Now run the commands manually and compare their output to script's
564 with open(filename, encoding="utf-8") as file:
565 script_commands = file.read().splitlines()
566
567 manual_out = []
568 manual_err = []
569 for cmdline in script_commands:
570 out, err = run_cmd(base_app, cmdline)
571 manual_out.extend(out)
572 manual_err.extend(err)
573
574 assert script_out == manual_out
575 assert script_err == manual_err
576
577
578@pytest.mark.parametrize("file_name", odd_file_names)

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…