@pytest.yield_fixture(scope='module')
def real_db():
 engine = main_engine()
 session = new_session(engine)
 (yield session)
 session.rollback()
 session.close()

@ pytest . yield_fixture ( scope = 'module' ) def real_db ( ) : engine = main_engine ( ) session = new_session ( engine ) ( yield session ) session . rollback ( ) session . close ( )
a fixture to get access to the real mysql db .