-
Notifications
You must be signed in to change notification settings - Fork 335
Closed
Description
Creating Postgres Container instance results in error: 'PostgresContainer' object has no attribute '_container'
I tried starting a Postgres container and got the following error:
Exception ignored in: <function DockerContainer.__del__ at 0x7f1da5122b80>
Traceback (most recent call last):
File "/.venv/lib/python3.9/site-packages/testcontainers/core/container.py", line 80, in __del__
AttributeError: 'PostgresContainer' object has no attribute '_container'
I already saw an issue #353 which was about the same error but it seems to persist.
See the code I used below.
To Reproduce
from testcontainers.postgres import PostgresContainer
def get_postgres_uri():
# Use a PostgreSQL Docker container for testing
with PostgresContainer("postgres:latest") as postgres:
return postgres.get_connection_url()
I also tried out the code in the postgres/tests/test_postgres.py file and it failed with the same error message.
Runtime environment
OS: Pop!_OS 22.04 LTS x86_64
Python version: Python 3.9.12
Docker version: 24.0.5
testcontainers version: 3.7.1
tobiaseisenschenk, shawnh310, pierrePinchonWefox and Tringy