Skip to content

Conversation

@pmorch
Copy link

@pmorch pmorch commented Dec 27, 2025

fix(core): Use WaitStrategy internally for wait_for function

Summary

Refactor the deprecated wait_for function to use the new WaitStrategy system internally instead of the @wait_container_is_ready decorator.

This fixes the import-time deprecation warning from #874.

See alexanderankin's comment stating core should no longer warn, and jonaslb's reply identifying that wait_for is still decorated with @wait_container_is_ready at module level, so it generates a warning.

Problem

The wait_for function was decorated with @wait_container_is_ready(), which emits a deprecation warning at decoration time (import time), not when the function is called. This caused warnings even when users never used wait_for.

Reproducer

mkdir /tmp/reproduce && cd /tmp/reproduce
echo 'import testcontainers.core.waiting_utils
def test_import(): pass' > test_import.py
uv run --with testcontainers --with pytest pytest test_import.py
=============================== warnings summary ===============================
waiting_utils.py:215: DeprecationWarning: The @wait_container_is_ready decorator
  is deprecated and will be removed in a future version...
    @wait_container_is_ready()

1 passed, 1 warning

Note: wait_for is never called - the warning is emitted just by importing the module.

Refactor the deprecated wait_for function to use the new WaitStrategy system
internally instead of the @wait_container_is_ready decorator.

The decorator emitted a deprecation warning at decoration time (import time),
causing warnings even when users never called wait_for.

Replace with an internal CallableWaitStrategy that uses WaitStrategy._poll()
for retry logic. This follows the intended migration path to the new system.

Fixes testcontainers#874
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant