Skip to content

How to use pytest.fixture in pytest.hookspec.pytest_configure #9580

Answered by nicoddemus
lixianwen asked this question in Q&A
Discussion options

You must be logged in to vote

If you want to share data between tests, fixtures are usually used, not hooks.

When databases are involved usually users define a session-scoped fixture which setups the database, and function-scoped fixtures which setup the database for some tests (usually with a rollback mechanism so tests using that fixture leave the database pristine).

Some articles describing the pattern:

Hope this helps!

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@lixianwen
Comment options

Answer selected by lixianwen
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants