pytest-dev / pytest

The pytest framework makes it easy to write small tests, yet scales to support complex functional testing
https://pytest.org
MIT License
11.66k stars 2.59k forks source link

"fixture not found" when test suite is network-mounted on Windows VM. #6948

Open stefanseefeld opened 4 years ago

stefanseefeld commented 4 years ago

I'm getting an error executing a pytest test case about a "fixture ... not found" when running on Windows 10 (Python 3.7 and Python 3.8). The same tests run fine on Linux.

My test suite contains a conftest.py file that defines a fixture 'module'. My test module then contains a test decorated with @pytest.mark.usefixtures('module').

Running this test on Linux works fine, but on Windows 10, I get the error

E fixture 'module' not found Running pytest --fixtures ... however lists the 'module' fixture, so I see it is being found.

Any idea what could be causing this ? Any suggestion how to debug this ?

This is pytest version 5.4.1, with the plugin pytest-asyncio-0.10.0

stefanseefeld commented 4 years ago

I have made some progress debugging this:

I could determine that the failure is path-dependent. As it happens, I'm developing a project mainly on Linux, then mounting the source directory into a Windows VM (Virtualbox) to test for portability. Thus, on WIndows, the directory hosting the project (and thus the test suite) is network-mounted in the WIndows VM. When I copy the test suite from its location ("Z:...") onto a native drive ("C:..."), everything works as expected. Note that the failure only affects fixtures defined in conftest.py, not in the test module itself. Any idea how to debug this further ? (At least I now have a workaround for my own project.)

I have changed the issue title to reflect my new finding.

Thanks,