pytest>=5.1.0 is unable to locate test nodes in modules when executed programmatically from a wheel installed on a Windows mapped network drive, if more than one node is passed to pytest.main #5835
Labels
platform: windows
windows platform-specific problem
type: regression
indicates a problem that was introduced in a release which was working previously
Basic description
I am in a situation where I'd like to be able to run tests from an installed wheel. Because (as I understand things) pytest custom arguments don't work when tests are invoked using a
pytest
command installed via a wheel (see #1596 and #3517), I am investigating an approach suggested by comments in those tickets, writing a test runner module that invokes pytest programmatically.I have found that in pytest versions before 5.1.0, the approach I've taken works. However, from 5.1.0 onwards, pytest sometimes cannot locate test modules/nodes when it is executed from a Windows mapped drive when invoked in ways that work on pre-5.1.0 builds.
I mentioned that it "sometimes" happens. From what I've observed, it happens if there are two or more nodes passed to
pytest.main
. If you call it with a module and a node (e.g.,blah/test/test_stuff.py
andblah/test/test_other_stuff.py::test_a
) it will work, but if you call it with two nodes (e.g.,blah/test/test_stuff.py::test_stuff
andblah/test/test_other_stuff.py::test_a
) it will fail to locate the function in the second module.Because of the nature of this issue and the version where it started reproducing, this looks like it may be somewhat related to an issue I reported recently, #5825.
pip list output
Platform info
OS version: Windows Server 2012R2
I've also reproduced this issue on 5.1.0. However, it fails to reproduce on 5.0.1.
Detailed description and repro info
I've created the repo https://github.com/paul-ko/runnable-test-repro to reproduce this issue. To summarize, the repo works like this:
runnablerepro/testdriver.py
implements a simple CLI for invoking tests via pytest. It takes one or more positional arguments, which it converts to file paths or pytest nodes, building them in ways that work correctly (in pre-5.1.0 versions of pytest) when executed from an installed wheel. Those paths/nodes are passed to pytest via a call topytest.main
, along with several optional parameters if they are specified.To set up for repro, do the following:
python setup.py bdist_wheel
to build a wheel.testdriver.exe test/test_fail.py::test_fail_2 test/test_pass.py::test_pass
If you have pytest 5.0.1 installed, you'll see a successful test run like this:
However, if you have pytest>=5.1.0 installed, you'll see an error locating a test
The odd thing is that this only seems to affect the second node; if I switch the order of the positional arguments it is now able to find
...test_pass.py::test_pass
but not...test_fail.py::test_fail
:This made me suspicious that something wrong with my code was causing this, but when I print the arguments I'm passing to
pytest.main
everything looks to be in order, and of course there's the fact that my code works with pre-5.1.0 versions of pytest.Additionally, it works on 5.1.0 and beyond if only one argument contains a node (i.e., the other arguments are just module filepaths):
The text was updated successfully, but these errors were encountered: