Closed ericpre closed 5 months ago
I have bumped into this as well, this is not that pytest_configure
is ignored but that it is only run in the xdist workers and not in the xdist controller when using pytest --pyargs
for some reason.
This can be an issue when setting up something in the xdist controller and accessing it in the xdist workers as in https://github.com/pytest-dev/pytest/issues/1402#issuecomment-186299177. In my case I want to set-up and random generator seed in the xdist controller and reuse it in the xdist workers to control random number generation.
If I get the time I'll try to put together a stand-alone example reproducing the issue.
this is expected - without collection only initial conftests are considered
as far as i am aware pyargs are not considered correctly for initial contests
i suspect this worked for you before by accident
i recommend using a autouse fixture and using something like https://pytest-xdist.readthedocs.io/en/latest/how-to.html#making-session-scoped-fixtures-execute-only-once to ensure it only happens once
OK thanks for your answer, I will need to have a closer look. I need the shared random seed in pytest_generate_tests
and I am not sure how I can do this with the autouse fixture yet ...
Thank you @RonnyPfannschmidt for the recommendation, it does work as expected!
When running the test suite with
pytest --pyargs package -n 2
, the content of thepytest_configure
hook inconftest.py
doesn't run:While it works fine when running
pytest -n 2
from the tests folder.