-
Notifications
You must be signed in to change notification settings - Fork 84
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
Add support for pytest-xdist #53
Conversation
@@ -69,6 +71,11 @@ def pytest_runtest_protocol(item, nextitem): | |||
# first item if necessary | |||
check_options(item.session.config) | |||
|
|||
parallel = hasattr(item.config, 'slaveinput') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might want to use getattr here to avoid BaseException shallowing
pytest_rerunfailures.py
Outdated
@@ -69,6 +71,11 @@ def pytest_runtest_protocol(item, nextitem): | |||
# first item if necessary | |||
check_options(item.session.config) | |||
|
|||
parallel = hasattr(item.config, 'slaveinput') | |||
plugins = [p[1] for p in item.config.pluginmanager.list_plugin_distinfo()] | |||
xdist = next((LooseVersion(p.version) for p in plugins if |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be better to write this as a function:
def works_with_current_xdist():
"""<explain details here>
"""
try:
d = pkg_resources.get_distribution('pytest-xdist')
return d.parsed_version >= pkg_resources.parse_version('1.20')
except pkg_resources.DistributionNotFound:
return None
And then later use it as:
if not parallel or works_with_current_xdist():
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well done! 👍
Currently, the README mentions the limitations with pytest-xdist. Are there still some limitations left, or is all fine now? In both cases it would be good to adjust the README. |
@sallner I've updated the README by removing the note about the reruns not being reflected in the output when using pytest-xdist. |
d0a25db
to
f61f658
Compare
@davehunt thanks for clarifying the readme |
@RonnyPfannschmidt @davehunt @nicoddemus I just carved out a new release of |
Thanks to @nicoddemus' fix in pytest-dev/pytest-xdist#218 we can now log reruns when using pytest-xdist. If users have an older version of pytest-xdist then they'll see the same behaviour as before, but as soon as they upgrade they'll get the additional log entries.