pytest: ImportPathMismatchError when on UNC path

Windows: When running pytest on a directory mounted as UNC path, this fail with ImportPathMismatchError:

c:\vagrant>pytest tests\\functional\\test_path_encodings.py
pytest tests\\functional\\test_path_encodings.py
Adding c:\python38\lib\site-packages\pywin32_system32 to sys.path
ImportError while loading conftest 'c:\vagrant\tests\functional\conftest.py'.
_pytest.pathlib.ImportPathMismatchError: ('conftest', 'c:\\vagrant\\tests\\functional\\conftest.py', WindowsPath('c:/vagrant/tests/functional/conftest.py'))

How to reproduce

  • Fire up a virtual maschine usine Vagrat and sharing the current directory (which contains the package)
  • Intall Python, pytest and requiremnets
  • Try running pytest

You can actually use the setup provided by PyInstaller:

git clone https://github.com/pyinstaller/pyinstaller.git
cd bootloader
# in Vagrantfile, line 434 (provision step "install packages") remove "vcbuildtools"
# … to save avoid installing this huge package
vagrant up --no-provision windows10
vagrant ssh windows10  # password is "Passw0rd!"
pip install -U pip
python -m pip install --upgrade pip setuptools wheel
pip install -U -r tests/requirements-tools.txt
pip install -e .
pytest tests/functional/test_path_encodings.py

C:\Users\IEUser>pip list Package Version Location


altgraph 0.17 apipkg 1.5 atomicwrites 1.4.0 attrs 20.1.0 colorama 0.4.3 execnet 1.7.1 flake8 3.8.3 future 0.18.2 iniconfig 1.0.1 lxml 4.5.2 mccabe 0.6.1 more-itertools 8.4.0 packaging 20.4 pefile 2019.4.18 pip 20.2.2 pluggy 0.13.1 psutil 5.7.2 py 1.9.0 pycodestyle 2.6.0 pyflakes 2.2.0 pyinstaller 4.1.dev0 \vboxsvr\vagrant
pyinstaller-hooks-contrib 2020.7 pyparsing 2.4.7 pytest 6.0.1 pytest-drop-dup-tests 0.3.0 pytest-forked 1.3.0 pytest-timeout 1.4.2 pytest-xdist 2.0.0 pywin32 228 pywin32-ctypes 0.2.0 setuptools 47.1.0 six 1.15.0 tinyaes 1.0.1 toml 0.10.1

System: Windows10, Python 3.8.5

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 29 (13 by maintainers)

Commits related to this issue

Most upvoted comments

Hmm I don’t actually know as it uses a new tool to me called devspace, not quite sure how the mounting works.

It copies the code into the container but there is some sort of magic sync going on I don’t yet understand how it works.

I can test this branch if you want? I am getting the same thing right now.

That would be great, thanks!

I reinstalled everything, and deleted the build folder, and it’s now working. So I am using pytest 6.0.1, not the one from the branch, but still the PY_IGNORE_IMPORTMISMATCH=1 is set