How to run setup in each pytest-xdist process

1.9k views Asked by At

When my test runner starts, I want to set some stuff up (adjust sys.path, add some environment variables, start some global fixtures). What hook can I use to make these changes in each xdist process that is spawned?

I've tried overloading a couple of the normal pytest hooks, but they are run before the subprocesses are launched.

1

There are 1 answers

0
dbn On BEST ANSWER

pytest_xdist has additional hooks that can be used in the conftest.py (list of hooks). The relevant hook for this purpose is pytest_configure_node(node), which is run after each new node is available and before it starts running tests.