diff --git a/core/testcontainers/core/waiting_utils.py b/core/testcontainers/core/waiting_utils.py index 9942854a..b186c0af 100644 --- a/core/testcontainers/core/waiting_utils.py +++ b/core/testcontainers/core/waiting_utils.py @@ -212,7 +212,6 @@ def wrapper(wrapped: Callable[..., Any], instance: Any, args: list[Any], kwargs: return cast("Callable[[F], F]", wrapper) -@wait_container_is_ready() def wait_for(condition: Callable[..., bool]) -> bool: warnings.warn( "The wait_for function is deprecated and will be removed in a future version. " @@ -222,7 +221,15 @@ def wait_for(condition: Callable[..., bool]) -> bool: DeprecationWarning, stacklevel=2, ) - return condition() + + class CallableWaitStrategy(WaitStrategy): + def wait_until_ready(self, container: WaitStrategyTarget) -> None: + pass # Required by ABC, but unused + + strategy = CallableWaitStrategy() + if not strategy._poll(condition): + raise TimeoutError(f"Condition not satisfied within {strategy._startup_timeout}s") + return True _NOT_EXITED_STATUSES = {"running", "created"}