Skip to content

Instantly share code, notes, and snippets.

@cozos
Created August 29, 2016 16:01
Show Gist options
  • Save cozos/a7292e386c7d8869c578bc85910026ae to your computer and use it in GitHub Desktop.
Save cozos/a7292e386c7d8869c578bc85910026ae to your computer and use it in GitHub Desktop.
@pytest.fixture(scope='function')
def db_session():
db_url = "postgresql://..."
engine = create_engine(db_url)
session = scoped_session(sessionmaker(bind=engine))
yield session
session.rollback()
session.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment