pytest-dev / pytest-dev/pytest-xdist

xdist fails on running individual tests

Open
#971 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug regression
Dominant language
Python
Stars
1.9k
Forks
287
Avg merge
9h 30m
Merged PRs (30d)
2

Description

With the upgrade of pytest-xdist from 2.5.0 to 3.x.y we observed that running individual tests by specifying them on the command line does not work anymore.
Consider the following folder structure with a single unit test in test_sample.py:
C:\project\tests\test_sample.py

We use socket servers, therefore running pytest in folder C:\project with the command line
pytest -d --tx socket=<test-runner>:8888 --rsyncdir C:\project
finds and executes the test on the remote machine as expected.

But specifying the test file on the command line to run only those tests does not work anymore with pytest-xdist 3.x.y while it worked in 2.5.0:
pytest -d --tx socket=<test-runner>:8888 --rsyncdir C:\project tests\test_sample.py

Similarly, starting pytest in folder C:\project\test with a slightly adapted command line did work in 2.5.0 but does not work anymore now:
pytest -d --tx socket=<test-runner>:8888 --rsyncdir C:\project test_sample.py

In both cases an error message is given: ValueError: arg tests\test_sample.py not relative to an rsync root

Using an absolute path for specifying the tests to run works. But this is not an option for us as we are using PyCharm to run individual tests directly from source code. There we have no control on the arguments it creates when calling pytest.

The regression was introduced in this commit: 25cc1a41 in file src/xdist/workermanage.py
In line 196 of the old version, py.path.local(parts[0]) prepended the given relative path in parts[0] with the current working directory. The new implementation using Path(parts[0]) does not do that, causing the relative path to be used further on and resulting in the observed error message.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/xdist/workermanage.py at the path handling changed by commit 25cc1a41, then reproduce the reported commands with relative test paths and --rsyncdir. Done means individual relative test files work with pytest-xdist 3.x.y while preserving the existing socket-worker behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
distributed-systems, testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.