import testing.postgresql
from sqlalchemy import create_engine
@pytest.fixture
def create_local_db():
with testing.postgresql.Postgresql() as postgresql:
engine = create_engine(postgresql.url())
yield engine
def test_example(create_local_db):
engine = create_local_db
with engine.connect() as conn:
res = [*conn.execute(f'SELECT 1;')]
assert res[0][0] == 1