Skip to content

Commit be47e0a

Browse files
chore: filter testcontainers deprecation warning and document bug
Filter the @wait_container_is_ready deprecation warning from testcontainers. The recommended replacement (HealthcheckWaitStrategy) has a bug with DockerCompose containers - it accesses wrapped.attrs which doesn't exist on ComposeContainer objects. Document the issue in test_integration.py with references to: - testcontainers/testcontainers-python#241 - testcontainers/testcontainers-python#144 Our ICAP-level polling approach is actually more robust as it verifies the protocol is responding, not just that the container is healthy.
1 parent b0ab620 commit be47e0a

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

‎pyproject.toml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ markers = [
5656
]
5757
timeout = 120 # Default timeout for all tests (seconds)
5858
timeout_method = "thread" # Use thread-based timeout for better compatibility
59+
filterwarnings = [
60+
# Ignore deprecation warning from testcontainers internals
61+
"ignore:The @wait_container_is_ready decorator is deprecated:DeprecationWarning",
62+
]
5963

6064
[tool.ruff]
6165
line-length = 100

‎tests/test_integration.py‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
11
"""
22
Integration tests for PyCap using testcontainers.
3+
4+
Wait Strategy Note:
5+
testcontainers emits a DeprecationWarning recommending migration from
6+
@wait_container_is_ready to structured wait strategies like
7+
HealthcheckWaitStrategy. However, these new strategies have a bug with
8+
DockerCompose containers:
9+
10+
- HealthcheckWaitStrategy accesses `wrapped.attrs.get("State", {}).get("Health", {})`
11+
- This assumes a Docker SDK container object with an `attrs` attribute
12+
- ComposeContainer.get_wrapped_container() returns a ComposeContainer, not a
13+
Docker SDK container, causing: AttributeError: 'ComposeContainer' object
14+
has no attribute 'attrs'
15+
16+
Relevant GitHub issues:
17+
- https://github.com/testcontainers/testcontainers-python/issues/241
18+
(Open since 2022: "Add wait_for_healthcheck method to DockerCompose")
19+
- https://github.com/testcontainers/testcontainers-python/issues/144
20+
(Similar pattern: wait_for_logs failed with DockerCompose)
21+
22+
Workaround:
23+
We filter the deprecation warning in pyproject.toml and use our own
24+
ICAP-level polling via wait_for_icap_service() for reliable service
25+
readiness detection. This approach is actually more robust as it verifies
26+
the ICAP protocol is responding, not just that the container is healthy.
327
"""
428

529
import time
@@ -57,7 +81,6 @@ def icap_service():
5781
with DockerCompose(str(docker_path), compose_file_name="docker-compose.yml"):
5882
# Wait for ICAP service to be ready (polls until OPTIONS succeeds)
5983
wait_for_icap_service(config["host"], config["port"], config["service"])
60-
6184
yield config
6285

6386

0 commit comments

Comments
 (0)