Skip to content

Commit

Permalink
test_that_pre_post_experiment_hook_works for all modes
Browse files Browse the repository at this point in the history
  • Loading branch information
yngve-sk committed Jan 6, 2025
1 parent 295ad53 commit eab7674
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions tests/ert/ui_tests/cli/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,16 +555,14 @@ def test_that_stop_on_fail_workflow_jobs_stop_ert(


@pytest.mark.usefixtures("copy_poly_case")
def test_that_pre_post_experiment_hook_works(
monkeypatch,
):
def test_that_pre_post_experiment_hook_works(monkeypatch, capsys):
monkeypatch.setattr(_ert.threading, "_can_raise", False)

# The executable
with open("hello_post_exp.sh", "w", encoding="utf-8") as f:
f.write(
dedent("""#!/bin/bash
echo "just sending regards" > from_post_experiment.txt
echo "just sending regards"
""")
)
os.chmod("hello_post_exp.sh", 0o755)
Expand All @@ -584,7 +582,7 @@ def test_that_pre_post_experiment_hook_works(
with open("hello_pre_exp.sh", "w", encoding="utf-8") as f:
f.write(
dedent("""#!/bin/bash
echo "first" > from_pre_experiment.txt
echo "first"
""")
)
os.chmod("hello_pre_exp.sh", 0o755)
Expand Down Expand Up @@ -617,14 +615,12 @@ def test_that_pre_post_experiment_hook_works(
)
)

run_cli(ITERATIVE_ENSEMBLE_SMOOTHER_MODE, "--disable-monitor", "poly.ert")
for mode in [ITERATIVE_ENSEMBLE_SMOOTHER_MODE, ES_MDA_MODE, ENSEMBLE_SMOOTHER_MODE]:
run_cli(mode, "--disable-monitor", "poly.ert")

assert (Path(os.getcwd()) / "from_pre_experiment.txt").read_text(
"utf-8"
) == "first\n"
assert (Path(os.getcwd()) / "from_post_experiment.txt").read_text(
"utf-8"
) == "just sending regards\n"
captured = capsys.readouterr()
assert "first" in captured.out
assert "just sending regards" in captured.out


@pytest.fixture(name="mock_cli_run")
Expand Down

0 comments on commit eab7674

Please sign in to comment.