-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Description
I've been (re-)learning pytest (used it last in the days where you had to get a snapshot of "py") and really like the new pytest, its documentation, and especially fixtures. However, there's one aspect of the documentation that I personally found lacking and really wish was clearer: how to reuse tests and fixtures across multiple test_*.py files. Other than the recommendation not to create a __init__.py
file in the root directory of the tests, there's little else (at least that I could find) on how to share test data and fixtures across python files.
Does pytest always add the root of the tests directory to sys.path (so we can use imports to pull in test data, etc. from a common module)? Should we put stuff in conftest.py instead? Googling these questions produces some hits, but they are sometimes unclear and/or contradictory. I wish there was some kind of official recommendation about this in the doc. I think it would be helpful.