-
Notifications
You must be signed in to change notification settings - Fork 248
Description
I am trying to add a new option to xdist's --dist flag. In my plugin.py file:
@pytest.hookimpl
def pytest_addoption(parser: pytest.Parser) -> None:
# Modify the existing xdist 'dist' option to add our new scheduling mode
group = parser.getgroup("xdist", "distributed and subprocess testing")
distopt = next(filter(lambda opt: opt.dest == "dist", group.options), None)
distopt._attrs["choices"].append("perdevice")The issue here is that I require xdist to have already added options before I can modify them. This is confusing me a bit because according to Pytest's documentation, plugin hooks are run on a LIFO basis - I would think since this new plugin is registered last, it would execute first.
In any case, the documentation also says you can influence the calls order using pytest.hookimpl(tryfirst=True). I haven't found this to work at all. Looking at the source code of xdist, the option for tryfirst isn't enabled, so I don't understand why this isn't working. Even adding trylast doesn't work.
Any ideas why this isn't working? I am using pytest-xdist 3.8.0 if that is relevant.