module-scoped fixture sharing a database connection leaks state between tests
pytest 7.4. I made a fixture that creates a temp SQLite DB with scope='module' to speed things up. Now tests fail because data leaks between them — one test inserts a row, the next one sees it. I thought module scope just meant the fixture function runs once, which is exactly what I wanted. How do people share an expensive resource without also sharing all the state sitting in it?
4 replies