From 906173e1135e8cc7fc8e83f068a9bddae27ada3d Mon Sep 17 00:00:00 2001 From: Fernando Pereira Date: Fri, 17 May 2024 09:21:08 +0100 Subject: [PATCH] Tests with subprocess should capture streams (#164) ## Context Not all tests using subprocess would capture std streams. This means pytest could not handle their output properly. Fixes #51 ## Scope Make all tests using subprocess capture std streams. ## Testing CI ## Review * [x] PR description is complete * [x] Coding style (imports, function length, New functions, classes or files) are good * [ ] Unit/Scientific test added * [ ] Updated Readme, in-code, developer documentation --- tests/integration-e2e/test_cli_opts.py | 6 ++++-- tests/integration-e2e/test_plugin.py | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/integration-e2e/test_cli_opts.py b/tests/integration-e2e/test_cli_opts.py index e8b290fd..f1c84e7b 100644 --- a/tests/integration-e2e/test_cli_opts.py +++ b/tests/integration-e2e/test_cli_opts.py @@ -39,9 +39,9 @@ def test_save_restore_cli(): # Save-Restore raises exception when using NEURON if simulator == "NEURON": with pytest.raises(subprocess.CalledProcessError): - subprocess.run(command, check=True) + subprocess.run(command, check=True, capture_output=True) else: - subprocess.run(command, check=True) + subprocess.run(command, check=True, capture_output=True) def test_cli_prcellgid(): @@ -70,6 +70,7 @@ def test_cli_disable_reports(): subprocess.run( ["neurodamus", CONFIG_FILE_MINI, "--disable-reports"], check=True, + capture_output=True, cwd=test_folder_path ) # Spikes are present even if we disable reports @@ -81,6 +82,7 @@ def test_cli_disable_reports(): subprocess.run( ["neurodamus", CONFIG_FILE_MINI], check=True, + capture_output=True, cwd=test_folder_path ) assert (test_folder_path / sim_config_data["output"]["output_dir"] / "out.h5").is_file() diff --git a/tests/integration-e2e/test_plugin.py b/tests/integration-e2e/test_plugin.py index f734aee4..0878057c 100644 --- a/tests/integration-e2e/test_plugin.py +++ b/tests/integration-e2e/test_plugin.py @@ -144,4 +144,5 @@ def test_run_acell_circuit(): ["bash", "tests/test_simulation.bash", str(simdir), "BlueConfig", ""], env=env, check=True, + capture_output=True, )