Skip to content

Commit

Permalink
Ensure missing runpath test is ran with plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
eivindjahren committed Oct 10, 2024
1 parent a06c971 commit 3dfec31
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
6 changes: 4 additions & 2 deletions tests/ert/ui_tests/cli/run_cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from argparse import ArgumentParser
from typing import Any, List
from typing import Any, List, Optional

from ert.__main__ import ert_parser
from ert.cli.main import run_cli as cli_runner
Expand All @@ -13,7 +13,9 @@ def run_cli(*args):
return res


def run_cli_with_pm(args: List[Any], pm: ErtPluginManager):
def run_cli_with_pm(args: List[Any], pm: Optional[ErtPluginManager] = None):
if pm is None:
pm = ErtPluginManager()
parser = ArgumentParser(prog="test_main")
parsed = ert_parser(parser, args)
res = cli_runner(parsed, pm)
Expand Down
8 changes: 5 additions & 3 deletions tests/ert/ui_tests/cli/test_missing_runpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from ert.cli.main import ErtCliError

from .run_cli import run_cli
from .run_cli import run_cli_with_pm

config_contents = """\
QUEUE_SYSTEM {queue_system}
Expand Down Expand Up @@ -55,7 +55,9 @@ def test_missing_runpath_has_isolated_failures(tmp_path, monkeypatch):
ErtCliError,
match=r"active realizations \(9\) is less than .* MIN_REALIZATIONS\(10\)",
):
run_cli("ensemble_experiment", "config.ert", "--disable-monitoring")
run_cli_with_pm(
["ensemble_experiment", "config.ert", "--disable-monitoring"]
)
finally:
with suppress(FileNotFoundError):
(tmp_path / "simulations/realization-0/iter-0").chmod(0x777)
Expand Down Expand Up @@ -95,4 +97,4 @@ def test_failing_writes_lead_to_isolated_failures(tmp_path, monkeypatch, pytestc
match=r"(?s)active realizations \(9\) is less than .* MIN_REALIZATIONS\(10\).*"
r"Driver reported: Could not create submit script: Don't like realization-1",
), patch_raising_named_temporary_file(queue_system.lower()):
run_cli("ensemble_experiment", "config.ert", "--disable-monitoring")
run_cli_with_pm(["ensemble_experiment", "config.ert", "--disable-monitoring"])
6 changes: 1 addition & 5 deletions tests/ert/ui_tests/cli/test_parameter_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from ert.field_utils import FieldFileFormat, Shape, read_field, save_field
from ert.field_utils.field_file_format import ROFF_FORMATS
from ert.mode_definitions import ENSEMBLE_EXPERIMENT_MODE
from ert.plugins import ErtPluginManager
from tests.ert.unit_tests.config.egrid_generator import egrids
from tests.ert.unit_tests.config.summary_generator import summaries

Expand Down Expand Up @@ -400,10 +399,7 @@ def test_parameter_example(
smspec.to_file("ECLBASE.SMSPEC")
unsmry.to_file("ECLBASE.UNSMRY")

run_cli_with_pm(
[ENSEMBLE_EXPERIMENT_MODE, "--disable-monitor", "config.ert"],
ErtPluginManager(),
)
run_cli_with_pm([ENSEMBLE_EXPERIMENT_MODE, "--disable-monitor", "config.ert"])

mask = np.logical_not(
np.array(io_source.actnum).reshape(io_source.dims, order="F")
Expand Down
6 changes: 1 addition & 5 deletions tests/ert/ui_tests/cli/test_shell.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import os
import os.path

from ert.plugins import ErtPluginManager

from .run_cli import run_cli_with_pm


Expand Down Expand Up @@ -37,9 +35,7 @@ def test_shell_scripts_integration(tmpdir):
with open("file.txt", "w", encoding="utf-8") as file_h:
file_h.write("something")

run_cli_with_pm(
["test_run", "--disable-monitor", ert_config_fname], ErtPluginManager()
)
run_cli_with_pm(["test_run", "--disable-monitor", ert_config_fname])

with open("realization-0/iter-0/moved.txt", encoding="utf-8") as output_file:
assert output_file.read() == "something"
Expand Down

0 comments on commit 3dfec31

Please sign in to comment.