Skip to content

Commit

Permalink
Fix regression from async forward_model
Browse files Browse the repository at this point in the history
  • Loading branch information
berland committed Nov 24, 2023
1 parent 82ccc29 commit 93c134d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
5 changes: 3 additions & 2 deletions tests/unit_tests/ensemble_evaluator/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
import stat
from pathlib import Path
from unittest.mock import MagicMock, Mock
from unittest.mock import AsyncMock, MagicMock, Mock

import pytest

Expand Down Expand Up @@ -64,9 +64,10 @@ def queue_config_fixture():
@pytest.fixture
def make_ensemble_builder(queue_config):
def _make_ensemble_builder(monkeypatch, tmpdir, num_reals, num_jobs, job_sleep=0):
forward_mock = AsyncMock(return_value=(LoadStatus.LOAD_SUCCESSFUL, ""))
monkeypatch.setattr(
"ert.job_queue.queue.forward_model_ok",
lambda _: (LoadStatus.LOAD_SUCCESSFUL, ""),
AsyncMock(return_value=(LoadStatus.LOAD_SUCCESSFUL, "")),
)
builder = ert.ensemble_evaluator.EnsembleBuilder()
with tmpdir.as_cwd():
Expand Down
4 changes: 2 additions & 2 deletions tests/unit_tests/job_queue/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import stat
from pathlib import Path
from unittest.mock import MagicMock
from unittest.mock import AsyncMock

import pytest

Expand All @@ -10,7 +10,7 @@

@pytest.fixture
def mock_fm_ok(monkeypatch):
fm_ok = MagicMock(return_value=(LoadStatus.LOAD_SUCCESSFUL, ""))
fm_ok = AsyncMock(return_value=(LoadStatus.LOAD_SUCCESSFUL, ""))
monkeypatch.setattr(ert.job_queue.queue, "forward_model_ok", fm_ok)
yield fm_ok

Expand Down
5 changes: 3 additions & 2 deletions tests/unit_tests/job_queue/test_job_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pathlib import Path
from threading import BoundedSemaphore
from typing import Any, Callable, Dict, List, Optional
from unittest.mock import MagicMock, patch
from unittest.mock import AsyncMock, MagicMock, patch

import pytest

Expand Down Expand Up @@ -195,7 +195,8 @@ async def test_run_done_callback(
):
monkeypatch.chdir(tmpdir)
monkeypatch.setattr(
"ert.job_queue.queue.forward_model_ok", lambda _: (loadstatus, "foo")
"ert.job_queue.queue.forward_model_ok",
AsyncMock(return_value=(loadstatus, "foo")),
)
job_queue = create_local_queue(simple_script)
execute_task = asyncio.create_task(job_queue.execute())
Expand Down

0 comments on commit 93c134d

Please sign in to comment.