Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions modules/postgres/tests/test_postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,21 @@ def test_none_driver_urls():

url = container.get_connection_url(driver=None)
assert url == expected_url


def test_psycopg_versions():
"""Test that both psycopg2 and psycopg (v2 and v3) work with the container."""

postgres_container = PostgresContainer("postgres:16-alpine", driver="psycopg2")
with postgres_container as postgres:
engine = sqlalchemy.create_engine(postgres.get_connection_url())
with engine.begin() as connection:
result = connection.execute(sqlalchemy.text("SELECT 1 as test"))
assert result.scalar() == 1

postgres_container = PostgresContainer("postgres:16-alpine", driver="psycopg")
with postgres_container as postgres:
engine = sqlalchemy.create_engine(postgres.get_connection_url())
with engine.begin() as connection:
result = connection.execute(sqlalchemy.text("SELECT 1 as test"))
assert result.scalar() == 1
Loading