SIGN IN SIGN UP

fix(core): Use WaitStrategy internally for wait_for function (#942)

# 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
https://github.com/testcontainers/testcontainers-python/issues/874.

See [alexanderankin's
comment](https://github.com/testcontainers/testcontainers-python/issues/874#issuecomment-3386026851)
stating core should no longer warn, and [jonaslb's
reply](https://github.com/testcontainers/testcontainers-python/issues/874#issuecomment-3442494671)
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

```bash
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.
P
Peter Valdemar Mørch committed
e323317838552a9f8046b2a8e24a03c07ff8890e
Parent: 183e1aa
Committed by GitHub <noreply@github.com> on 1/19/2026, 5:45:40 PM