Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-eq committed Nov 21, 2024
1 parent 59852cb commit 4de22d3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def mocked_process(pid):
return MockedProcess(123)

monkeypatch.setattr(forward_model_step, "Process", mocked_process)
(_, _, oom_score) = _get_processtree_data(MockedProcess(123))
(_, _, oom_score) = _get_processtree_data(123)

assert oom_score == 456

Expand Down
14 changes: 9 additions & 5 deletions tests/ert/unit_tests/forward_model_runner/test_job_dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import sys
from subprocess import Popen
from textwrap import dedent
from unittest.mock import mock_open

import pandas as pd
import psutil
Expand Down Expand Up @@ -357,16 +356,21 @@ async def test_job_dispatch_kills_itself_after_unsuccessful_job(
):
host = "localhost"
port = unused_tcp_port
jobs_json = json.dumps(
{"ens_id": "_id_", "dispatch_url": f"ws://localhost:{port}", "jobList": []}
)
jobs_obj = {
"ens_id": "_id_",
"dispatch_url": f"ws://localhost:{port}",
"jobList": [],
}
print(os.getcwd())
with open("jobs.json", mode="w+", encoding="utf-8") as f: # noqa: ASYNC230
json.dump(jobs_obj, f)

async def mock_run_method(self: ForwardModelRunner, *args, **kwargs):
await self.put_event(Init([], 0, 0))
await self.put_event(Finish().with_error("overall bad run"))

monkeypatch.setattr(ForwardModelRunner, "run", mock_run_method)
monkeypatch.setattr("builtins.open", mock_open(read_data=jobs_json))
# monkeypatch.setattr(_ert.forward_model_runner.cli, "builtins.open", mock_open(read_data=jobs_json))
async with _mock_ws_task(host, port, []):
with pytest.raises(ForwardModelRunnerException):
await main(["script.py"])
Expand Down

0 comments on commit 4de22d3

Please sign in to comment.