pytest-dev / pytest-forked

extracted --boxed from pytest-xdist to ensure backward compat
MIT License
62 stars 21 forks source link

Why pytest-forked helps ? #28

Closed jhagege closed 4 years ago

jhagege commented 4 years ago

Hi, I have been usign the pytest-forked plugin which is very helpful. I am wondering why sometimes tests failed when they are ran one after the other, but then pass when they are ran in separate processes thanks to your plugin. I have a use case where I'd like to work with regular pytest (without --forked) option, and I am trying to troubleshoot why one test is failing after another when running without --forked.

Thanks for any hints.

RonnyPfannschmidt commented 4 years ago

in general, pytest-forked separates setup/teardown and shared state in processes, so in a sense it makes accidentally shared state dependent tests pseudo-separated by introducing process isolation

so if a test set works with --forked but fails without,, it points to a state dependency somewhere in the fixtures/setup/teardown or general global state of a module