| 547 | |
| 548 | |
| 549 | def 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) |