Commit e323317
authored
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
#874.
See [alexanderankin's
comment](#874 (comment))
stating core should no longer warn, and [jonaslb's
reply](#874 (comment))
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.1 parent 183e1aa commit e323317
1 file changed
+9
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
216 | 216 | | |
217 | 217 | | |
218 | 218 | | |
219 | | - | |
220 | 219 | | |
221 | 220 | | |
222 | 221 | | |
| |||
226 | 225 | | |
227 | 226 | | |
228 | 227 | | |
229 | | - | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
230 | 237 | | |
231 | 238 | | |
232 | 239 | | |
| |||
0 commit comments