Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New xdist APIs #122

Closed
tucked opened this issue Jul 2, 2021 · 1 comment
Closed

New xdist APIs #122

tucked opened this issue Jul 2, 2021 · 1 comment

Comments

@tucked
Copy link

tucked commented Jul 2, 2021

pytest-dev/pytest-xdist#505

Seems like an upstreamed version of _is_master:
https://github.com/dbader/pytest-mypy/blob/3dc75dfc5c4ae6ee6dc0d35b88f7898221c3d089/src/pytest_mypy.py#L53-L58

Maybe this project should take advantage of them 🤔

@dmtucker
Copy link
Collaborator

is_xdist_master is not a drop-in replacement for _is_master for a couple reasons:

  • It takes request_or_session instead of config.
    The only way I know of to get the former from the latter is:
    config.pluginmanager.getplugin("session")
  • It returns False if xdist is not active.
    We could get around this by using not is_xdist_worker.

Even though we could make it work, I see 2 problems with proceeding:

  1. No APIs can replace _get_xdist_workerinput (which isn't surprising, since it's a compatibility shim -- but even ignoring that, we still have to know about config.workerinput).
  2. Accessing the APIs requires accessing xdist, which we'd probably want a helper function for:
    xdist = config.pluginmanager.getplugin("xdist")
    if not (xdist and xdist.is_xdist_worker(config.pluginmanager.getplugin("session"))):
    That basically just means re-implementing _is_master in a slower (though, perhaps more correct) way.

I think 1 is really the deal-breaker. The only way we can justify making _is_master slower is if it is indeed more correct. By that I mean: xdist could redefine how to identify an xdist worker without breaking us. If they did that, though, _get_xdist_workerinput would most likely still break.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants