Skip to content

xdist fails on running individual tests #971

Open
@dankob00

Description

@dankob00

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: 25cc1a4 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions