pytest-postgres is an plugin for pytest, for adding PostgreSQL database as service into Docker container for tests.
import psycopg2
def test_pg_server(pg_server):
pg_params = pg_server['pg_params']
with psycopg2.connect(**pg_params) as conn:
with conn.cursor() as cursor:
cursor.execute('SELECT version();')
pytest-postgres has been strongly influenced by pytest-asyncio.
To install pytest-postgres, do:
(env) $ pip install pytest-postgres
0.1.1 (2017-07-20)
Repair [issue](https://github.com/clayman74/pytest-postgres/issues/2)
0.1.0 (2016-09-15)
Initial release.