pytest.main() and plugin registration #1169
sashko1988
started this conversation in
General
Replies: 1 comment 2 replies
-
Because it cannot know how to create these objects Plugins must explicitly handle this themselves |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Why doesn't xdist pass the plugin list to workers when pytest is called with
pytest.main()
?Imagine a wrapper that calls pytest like that -
pytest.main(args, ["package.needed_plugins"])
. Andneeded_plugins
adds cli option and process that option.Every time pytest is invoked in distribution mode - workers will crash because of an unrecognized argument (which is added and processed by one of the plugins)
When xdist creates a worker, it always passes
plugins=None
topytest._prepareconfig
:config = _prepareconfig(args, None)
(https://github.com/pytest-dev/pytest-xdist/blob/master/src/xdist/remote.py#L418)
Unexpectedly, the plugin registered without troubles in the controller node isn't passed to workers.
WORKAROUND
Load plugins passing them in args using
-p
argument (https://docs.pytest.org/en/stable/how-to/writing_plugins.html#plugin-discovery-order-at-tool-startup point 3)Beta Was this translation helpful? Give feedback.
All reactions