New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

numirias opened this Issue Jan 23, 2018 · 2 comments


None yet
4 participants

numirias commented Jan 23, 2018

If I invoke pytest.main(['']) multiple time from the same running script, it will give the same result, even if 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.)


This comment has been minimized.


RonnyPfannschmidt commented Jan 23, 2018

python modules cache in side the same process and due to this property of python its not advisable to run pytest.main twice from the same process

while there may be exceptions to that rule, in general its more safe to run a new process since python is not safe for code reloading


This comment has been minimized.


nicoddemus commented Jan 23, 2018

I agree, we should just add a note to the docs regarding that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment