I have a test file that I run with pytest
The file has parametrized tests and also a setup that I want it to run only once before any of the tests run, on that setup I do actions that can't be done in parallel (Write to text files).
That setup is like this
@pytest.fixture(scope="session", autouse=True)
def before_all_tests(request):
# Code that I want to run only once before all tests start to run
When I run with no -n parameter everything works OK
When I run with -n then I have issues that I understand that are because two threads are doing the setup at the same time
Is this the way xdist works ? The setup is doing per thread ? Is there any scope that ensures me that the setup is doing only once before each thread starts to run tests ?