Skip to content

bug: community modules using old decorators print deprecation warnings #874

@DarthMax

Description

@DarthMax

It seems that the 4.13 release introduced a new deprecation warning around the @wait_container_is_ready decorator.

The deprecation warning itself works as expected and the description is comprehensive.
There is a problem however: importing DockerContainer will cause the deprecation warning to appear with the following stack trace:

conftest.py:6: in <module>
    from testcontainers.core.container import DockerContainer
project/venv/lib/python3.13/site-packages/testcontainers/core/container.py:21: in <module>
    from testcontainers.core.wait_strategies import LogMessageWaitStrategy
project/venv/lib/python3.13/site-packages/testcontainers/core/wait_strategies.py:41: in <module>
    from .waiting_utils import WaitStrategy, WaitStrategyTarget
project/venv/lib/python3.13/site-packages/testcontainers/core/waiting_utils.py:178: in <module>
    @wait_container_is_ready()
project/venv/lib/python3.13/site-packages/testcontainers/core/waiting_utils.py:117: in wait_container_is_ready
    warnings.warn(
E   DeprecationWarning: The @wait_container_is_ready decorator is deprecated and will be removed in a future version. Use structured wait strategies instead: container.waiting_for(HttpWaitStrategy(8080).for_status_code(200)) or container.waiting_for(LogMessageWaitStrategy('ready'))

Our project is configured to treat warnings as errors. As far as I am aware, there is currently nothing we can do on the consumer side to prevent this issues.

As a side note, the documentation still mentions the wait_for_logs method:
https://testcontainers-python.readthedocs.io/en/latest/core/README.html

To Reproduce

from testcontainers.core.container import DockerContainer
template details

Runtime environment

Provide a summary of your runtime environment. Which operating system, python version, and docker version are you using? What is the version of testcontainers-python you are using? You can run the following commands to get the relevant information.

# Get the operating system information (on a unix os).
$ uname -a
Linux computer 6.16.5-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 04 Sep 2025 23:18:13 +0000 x86_64 GNU/Linux
# Get the python version.
$ python --version
Python 3.13.7
# Get the docker version and other docker information.
$ docker info
Client:
 Version:    28.3.3
 Context:    default
 Debug Mode: false
 Plugins:
  compose: Docker Compose (Docker Inc.)
    Version:  2.39.2
    Path:     /usr/lib/docker/cli-plugins/docker-compose

Server:
 Containers: 18
  Running: 0
  Paused: 0
  Stopped: 18
 Images: 89
 Server Version: 28.3.3
 Storage Driver: overlay2
  Backing Filesystem: btrfs
  Supports d_type: true
  Using metacopy: true
  Native Overlay Diff: false
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 CDI spec directories:
  /etc/cdi
  /var/run/cdi
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 75cb2b7193e4e490e9fbdc236c0e811ccaba3376.m
 runc version: 
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.16.5-arch1-1
 Operating System: Arch Linux
 OSType: linux
 Architecture: x86_64
 CPUs: 22
 Total Memory: 62.23GiB
 Name: kaylee
 ID: 255a32ed-e357-4e07-be9f-c97413711ef9
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  ::1/128
  127.0.0.0/8
 Live Restore Enabled: false

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions