Skip to content

How to correctly run pytest.main() programmatically multiple times? #3143

@numirias

Description

@numirias

If I invoke pytest.main(['test_foo.py']) multiple time from the same running script, it will give the same result, even if test_foo.py changes between the runs. (This was also observed in #793.)

But then what is the correct way to rerun pytest programmatically? Could you point me to an example? Starting it in a subprocess feels quite clunky and also makes it more cumbersome to process the results.

(Also, could we possibly have a note about that behavior in the docs? At least to me, it was somewhat unexpected that I can't run pytest.main() in the same script twice.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueeasy issue that is friendly to new contributortype: 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