Add comment to session fixture

This commit is contained in:
Sergey Golitsynskiy
2021-10-21 22:55:51 -04:00
parent 649ed292f1
commit 57997a9230
+10
View File
@@ -11,6 +11,16 @@ def engine():
@pytest.fixture
def session(init_model, engine):
"""
init_model is a fixture that must be defined in the test module using the
session fixture (or in any other discoverable location). Ideally, it will
have module scope and will initialize the models in the database. It must
use the same engine as this fixture. For example:
@pytest.fixture(scope='module')
def init_model(engine):
model.mapper_registry.metadata.create_all(engine)
"""
session_factory = sessionmaker(bind=engine)
Session = scoped_session(session_factory)
yield Session()