pytest-xdist icon indicating copy to clipboard operation
pytest-xdist copied to clipboard

No "master" worker_id in session fixture

Open andrewVolodko opened this issue 1 year ago • 0 comments

I want to perform the particular action only once per test run. As mentioned here, it can be done by checking, that now it's a master worker. https://pytest-xdist.readthedocs.io/en/latest/how-to.html#making-session-scoped-fixtures-execute-only-once

But there is no worker with id = "master".

Here is my code:

    @fixture(scope="session", autouse=True)
    def session_setup(self, worker_id):
        if worker_id == "master":
            print()

BTW, there is no master worker only when I'm running tests in parallel with flag -n 2 or more.

andrewVolodko avatar Feb 28 '24 23:02 andrewVolodko