From cd2f87d11e4db5598cf481f69bd056e1a3de585c Mon Sep 17 00:00:00 2001 From: Andreas Eknes Lie Date: Wed, 20 Sep 2023 13:05:42 +0200 Subject: [PATCH] Update signatures for pybind Fix job_queue test patch --- src/ert/job_queue/queue.py | 7 ++----- tests/unit_tests/job_queue/test_job_queue.py | 19 ++++++++----------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/ert/job_queue/queue.py b/src/ert/job_queue/queue.py index ecb9ffce3f8..9d2c45322fb 100644 --- a/src/ert/job_queue/queue.py +++ b/src/ert/job_queue/queue.py @@ -88,10 +88,8 @@ def _queue_state_event_type(state: str) -> str: # pylint: disable=too-many-public-methods class JobQueue(BaseCClass): # type: ignore TYPE_NAME = "job_queue" - _alloc = ResPrototype("void* job_queue_alloc()", bind=False) + _alloc = ResPrototype("void* job_queue_alloc(void*)", bind=False) _free = ResPrototype("void job_queue_free( job_queue )") - _set_driver = ResPrototype("void job_queue_set_driver( job_queue , void* )") - _add_job = ResPrototype("int job_queue_add_job_node(job_queue, job_queue_node)") def __repr__(self) -> str: @@ -112,11 +110,10 @@ def __init__(self, driver: "Driver", max_submit: int = 2): self.job_list: List[JobQueueNode] = [] self._stopped = False - c_ptr = self._alloc(STATUS_file, ERROR_file) + c_ptr = self._alloc(driver.from_param(driver)) super().__init__(c_ptr) self.driver = driver - self._set_driver(driver.from_param(driver)) self._differ = QueueDiffer() self._max_job_duration = 0 self._max_submit = max_submit diff --git a/tests/unit_tests/job_queue/test_job_queue.py b/tests/unit_tests/job_queue/test_job_queue.py index dba7b10f551..98a5cd0015e 100644 --- a/tests/unit_tests/job_queue/test_job_queue.py +++ b/tests/unit_tests/job_queue/test_job_queue.py @@ -331,17 +331,14 @@ def test_stop_long_running(): job_list[i]._start_time = 0 job_list[i]._end_time = 5 - # The driver is of no consequence, so resolving it in the c layer is - # uninteresting and mocked out. - with patch("ert.job_queue.JobQueue._set_driver"): - queue = JobQueue(MagicMock()) - - # We don't need the c layer call here, we only need it added to - # the queue's job_list. - with patch("ert.job_queue.JobQueue._add_job") as _add_job: - for idx, job in enumerate(job_list): - _add_job.return_value = idx - queue.add_job(job, idx) + queue = JobQueue(MagicMock()) + + # We don't need the c layer call here, we only need it added to + # the queue's job_list. + with patch("ert.job_queue.JobQueue._add_job") as _add_job: + for idx, job in enumerate(job_list): + _add_job.return_value = idx + queue.add_job(job, idx) queue.stop_long_running_jobs(5) queue._differ.transition(queue.job_list)