I need to execute some setup (like creating a socket) inside each of the processes created by xdist before the processes start running the tests. I have looked at the hooks provided by xdist, but both pytest_configure_node()
and pytest_testnodeready()
seem to be executed by the main process instead of the subprocesses. Is there a way to do this?
Thanks.
Asked
Active
Viewed 558 times
1

user197674
- 748
- 2
- 7
- 22
1 Answers
1
the pytest_configure(config)
hook is also executed on the slaves
just check of there is a config.slaveinput
i recall there are some examples in the builtin junitxml plugin
edit: link to code: https://github.com/pytest-dev/pytest/blob/master/_pytest/junitxml.py#L225
-
Note that `slaveinput` was renamed to `workerinput` with the deprecation of the "slave" terminology: https://github.com/pytest-dev/pytest/commit/564b2f707dd558d10974268ab5a5494de2f90238#diff-40c29b1f1136f0a212e98384b44450adaf2c8808fdf14084d4ce78d63dc9d866R431 – Tomasito665 May 18 '21 at 18:42