Skip to content

Fix rsyncdirs usage with pytest 6.0 #558

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

Merged
merged 1 commit into from
Jul 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/558.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix ``rsyncdirs`` usage with pytest 6.0.
12 changes: 10 additions & 2 deletions src/xdist/workermanage.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,16 @@ def _getrsyncdirs(self):
import pytest
import _pytest

pytestpath = pytest.__file__.rstrip("co")
pytestdir = py.path.local(_pytest.__file__).dirpath()
def get_dir(p):
"""Return the directory path if p is a package or the path to the .py file otherwise."""
stripped = p.rstrip("co")
if os.path.basename(stripped) == "__init__.py":
return os.path.dirname(p)
else:
return stripped

pytestpath = get_dir(pytest.__file__)
pytestdir = get_dir(_pytest.__file__)
config = self.config
candidates = [py._pydir, pytestpath, pytestdir]
candidates += config.option.rsyncdir
Expand Down
1 change: 0 additions & 1 deletion testing/acceptance_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ def test_crash():
)
assert result.ret == 1

@pytest.mark.xfail(reason="#527: Ignore Python 3.8 failure for the time being")
def test_distribution_rsyncdirs_example(self, testdir, monkeypatch):
# use a custom plugin that has a custom command-line option to ensure
# this is propagated to workers (see #491)
Expand Down