From 325e8dcdff322ffdc978875f5a8577e1fde73198 Mon Sep 17 00:00:00 2001 From: Brian Schubert Date: Mon, 11 Sep 2023 11:26:20 -0400 Subject: [PATCH] Add test for CLI --exec output matching direct execution output --- test/test_cli.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/test/test_cli.py b/test/test_cli.py index 69e1b42..c6abe6f 100644 --- a/test/test_cli.py +++ b/test/test_cli.py @@ -49,8 +49,28 @@ def test_bad_path() -> None: sixs_cli.main(["--path"]) -@pytest.mark.parametrize("version", sixs_bin._SIXS_BINARIES.keys()) -def test_exec_eof(version) -> None: +def test_exec_matches(sixs_version, manual_input_file) -> None: + """ + Verify that output when using ``--exec`` exactly matches the output of directly + calling the binary. + """ + proc_args = { + "input": manual_input_file, + "capture_output": True, + "check": True, + "text": True, + "encoding": "ascii", + } + + direct_result = subprocess.run([sixs_bin.get_path(sixs_version)], **proc_args) + + cli_result = _run_self_subprocess(["--exec", sixs_version], **proc_args) + + assert direct_result.returncode == cli_result.returncode + assert direct_result.stdout == cli_result.stdout + assert direct_result.stderr == cli_result.stderr + + def test_exec_eof(sixs_version) -> None: """Check error message on empty input file.""" with pytest.raises(subprocess.CalledProcessError) as exec_info: