title: factoryboy pytest session management
body: <p>I am using pytest as framework for testing my application and I want to use pytest factoryboy as well. Thusfar, my conftest.py looks pretty much like the example:</p>
  
  <pre><code>import factory
  from sqlalchemy import create_engine
  from sqlalchemy.orm import scoped_session, sessionmaker
  from model import model
  
  engine = create_engine('sqlite://')
  session = scoped_session(sessionmaker(bind=engine))
  
  # Create tables
  model.Base.metadata.create_all(engine)
  
  class ExampleFactory(factory.alchemy.SQLAlchemyModelFactory):
  
      class Meta:
          model = model.ExampleClass
          sqlalchemy_session = session
  
      label = factory.Sequence(lambda n: u'object_%d' % n)
  </code></pre>
  
  <p>I have multiple factories like this. The problem is that when I use factories in this manner, the session will not be torn down every unit test. I'm basically using one big session for the lot of unit tests that I have. Not very ideal. Using fixtures I could refresh a session every unit test. Is there a way to do this using factoryboy pytest?</p>