-
Couldn't load subscription status.
- Fork 42
Closed
Description
I have the following fixtures:
@pytest.yield_fixture(scope='session')
def db_url():
with testing.postgresql.Postgresql() as db:
yield db.url()
@pytest.yield_fixture
def db(db_url):
"""Create a database session."""
engine = sqlalchemy.create_engine(db_url)
models.metadata.create_all(engine)
factories.Session.configure(bind=engine)
session = factories.Session() # creates the thread local session used by factories
yield session
session.rollback()
factories.Session.remove() # disables the thread local session
models.metadata.drop_all(engine)
pytest_factoryboy.register(factories.BookFactory)My problem now is that trying to use the book_factory fixture on its own doesn't work; I need the db fixture to open a session the factory can use, first.
I'd like to be able to specify something like
pytest_factoryboy.register(factories.BookFactory, depends_on=['db'])which would have the same effect as the manual implementation of
def book_factory(db):
# …would.
Metadata
Metadata
Assignees
Labels
No labels