Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace _wait_until with wait_until #9962

Merged
merged 1 commit into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import time

import pytest

Expand All @@ -24,13 +23,6 @@
from tests.ert.utils import MockZMQServer


def _wait_until(condition, timeout, fail_msg):
start = time.time()
while not condition():
assert start + timeout > time.time(), fail_msg
time.sleep(0.1)


def test_report_with_successful_start_message_argument(unused_tcp_port):
host = "localhost"
url = f"tcp://{host}:{unused_tcp_port}"
Expand Down
17 changes: 5 additions & 12 deletions tests/ert/unit_tests/forward_model_runner/test_fm_dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,10 @@
)
from _ert.forward_model_runner.forward_model_step import killed_by_oom
from _ert.forward_model_runner.reporting import Event, Interactive, Reporter
from _ert.forward_model_runner.reporting.message import (
Finish,
Init,
Message,
)
from _ert.forward_model_runner.reporting.message import Finish, Init, Message
from _ert.threading import ErtThread
from tests.ert.utils import MockZMQServer, wait_until

from .test_event_reporter import _wait_until


@pytest.mark.integration_test
@pytest.mark.usefixtures("use_tmpdir")
Expand Down Expand Up @@ -313,11 +307,10 @@ def test_retry_of_jobs_json_file_read(unused_tcp_port, tmp_path, monkeypatch, ca
)

def create_jobs_file_after_lock():
_wait_until(
lambda: f"Could not find file {FORWARD_MODEL_DESCRIPTION_FILE}, retrying"
in caplog.text,
2,
f"Did not get expected log message from missing {FORWARD_MODEL_DESCRIPTION_FILE}",
wait_until(
lambda: f"Could not find file {FORWARD_MODEL_DESCRIPTION_FILE}, retrying",
interval=0.1,
timeout=2,
)
(tmp_path / FORWARD_MODEL_DESCRIPTION_FILE).write_text(jobs_json)
lock.release()
Expand Down