Skip to content

Wish documentation was clearer on recommended way to structure tests and fixtures across files #1505

@chrish42

Description

@chrish42

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: docsdocumentation improvement, missing or needing clarification

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions