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

Function test_run_script_with_utf8_file

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

Source from the content-addressed store, hash-verified

431
432
433def test_run_script_with_utf8_file(base_app, request) -> None:
434 test_dir = os.path.dirname(request.module.__file__)
435 filename = os.path.join(test_dir, "scripts", "utf8.txt")
436
437 assert base_app._script_dir == []
438 assert base_app._current_script_dir is None
439
440 # Get output out the script
441 script_out, script_err = run_cmd(base_app, f"run_script {filename}")
442 assert base_app.last_result is True
443
444 assert base_app._script_dir == []
445 assert base_app._current_script_dir is None
446
447 # Now run the commands manually and compare their output to script's
448 with open(filename, encoding="utf-8") as file:
449 script_commands = file.read().splitlines()
450
451 manual_out = []
452 manual_err = []
453 for cmdline in script_commands:
454 out, err = run_cmd(base_app, cmdline)
455 manual_out.extend(out)
456 manual_err.extend(err)
457
458 assert script_out == manual_out
459 assert script_err == manual_err
460
461
462def test_scripts_add_to_history(base_app, request) -> 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…