From 38afca8593061ccb493950773f4d1096ba2a0c4a Mon Sep 17 00:00:00 2001 From: Eivind Jahren Date: Tue, 1 Oct 2024 16:37:55 +0200 Subject: [PATCH] Extract common code path in test fixtures --- tests/ert/ui_tests/gui/conftest.py | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/tests/ert/ui_tests/gui/conftest.py b/tests/ert/ui_tests/gui/conftest.py index d3f038dddf4..48be57d0afd 100644 --- a/tests/ert/ui_tests/gui/conftest.py +++ b/tests/ert/ui_tests/gui/conftest.py @@ -215,28 +215,26 @@ def esmda_has_run(_esmda_run, tmp_path, monkeypatch): def ensemble_experiment_has_run( tmp_path, monkeypatch, run_experiment, source_root, tmp_path_factory ): - monkeypatch.chdir(tmp_path) - test_files = _ensemble_experiment_run( - run_experiment, source_root, tmp_path_factory, True + yield from _ensemble_experiment_has_run( + tmp_path, monkeypatch, run_experiment, source_root, tmp_path_factory, True ) - shutil.copytree(test_files, tmp_path, dirs_exist_ok=True) - with _open_main_window(tmp_path / "poly.ert") as ( - gui, - _, - config, - ), StorageService.init_service( - project=os.path.abspath(config.ens_path), - ): - yield gui @pytest.fixture def ensemble_experiment_has_run_no_failure( tmp_path, monkeypatch, run_experiment, source_root, tmp_path_factory +): + yield from _ensemble_experiment_has_run( + tmp_path, monkeypatch, run_experiment, source_root, tmp_path_factory, False + ) + + +def _ensemble_experiment_has_run( + tmp_path, monkeypatch, run_experiment, source_root, tmp_path_factory, failing ): monkeypatch.chdir(tmp_path) test_files = _ensemble_experiment_run( - run_experiment, source_root, tmp_path_factory, False + run_experiment, source_root, tmp_path_factory, not failing ) shutil.copytree(test_files, tmp_path, dirs_exist_ok=True) with _open_main_window(tmp_path / "poly.ert") as (