File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -133,3 +133,21 @@ def test_none_driver_urls():
133133
134134 url = container .get_connection_url (driver = None )
135135 assert url == expected_url
136+
137+
138+ def test_psycopg_versions ():
139+ """Test that both psycopg2 and psycopg (v2 and v3) work with the container."""
140+
141+ postgres_container = PostgresContainer ("postgres:16-alpine" , driver = "psycopg2" )
142+ with postgres_container as postgres :
143+ engine = sqlalchemy .create_engine (postgres .get_connection_url ())
144+ with engine .begin () as connection :
145+ result = connection .execute (sqlalchemy .text ("SELECT 1 as test" ))
146+ assert result .scalar () == 1
147+
148+ postgres_container = PostgresContainer ("postgres:16-alpine" , driver = "psycopg" )
149+ with postgres_container as postgres :
150+ engine = sqlalchemy .create_engine (postgres .get_connection_url ())
151+ with engine .begin () as connection :
152+ result = connection .execute (sqlalchemy .text ("SELECT 1 as test" ))
153+ assert result .scalar () == 1
You can’t perform that action at this time.
0 commit comments