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

Add support for pytest-xdist #53

Merged
merged 3 commits into from
Aug 28, 2017
Merged

Conversation

davehunt
Copy link
Contributor

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.

@@ -69,6 +71,11 @@ def pytest_runtest_protocol(item, nextitem):
# first item if necessary
check_options(item.session.config)

parallel = hasattr(item.config, 'slaveinput')
Copy link
Member

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

@@ -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
Copy link
Member

@nicoddemus nicoddemus Aug 18, 2017

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():

Copy link
Member

@nicoddemus nicoddemus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well done! 👍

@sallner
Copy link
Member

sallner commented Aug 21, 2017

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.
Apart from that, well done.

@davehunt
Copy link
Contributor Author

@sallner I've updated the README by removing the note about the reruns not being reflected in the output when using pytest-xdist.

@sallner sallner merged commit 5d528e5 into pytest-dev:master Aug 28, 2017
@sallner
Copy link
Member

sallner commented Aug 28, 2017

@davehunt thanks for clarifying the readme

@sallner
Copy link
Member

sallner commented Aug 29, 2017

@RonnyPfannschmidt @davehunt @nicoddemus I just carved out a new release of pytest-rerunfailures with the support for pytest-xdist included.

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

Successfully merging this pull request may close these issues.

4 participants