Skip to content

File path not correct when using drive with subst in Windows #5965

@fabioz

Description

@fabioz

To reproduce the issue, let's say you have a file structure such as:

c:\temp\somedir\test_it.py

with the contents:

def test_it():
    raise AssertionError(__file__)

then, do a subst for the c:\temp\somedir to T:

i.e.:

subst t: c:\temp\somedir

Then go to T: and run the test:

cd /D T:
python -m pytest test_it.py 

The output I have when running it with pytest 5.2.1 is:

 c:\bin\Python37-32\python.exe -m pytest test_it.py
================================ test session starts ================================ 
platform win32 -- Python 3.7.4, pytest-5.2.1, py-1.8.0, pluggy-0.13.0
rootdir: C:\temp\somedir
collected 1 item

test_it.py F                                                                   [100%]

===================================== FAILURES ====================================== 
______________________________________ test_it ______________________________________

    def test_it():
>       raise AssertionError(__file__)
E       AssertionError: C:\temp\somedir\test_it.py

C:\temp\somedir\test_it.py:3: AssertionError
================================= 1 failed in 0.03s =================================

whereas on pytest 5.0.1 it was correct (as shown below)

c:\bin\Python37-32\python.exe -m pytest test_it.py
================================ test session starts ================================ 
platform win32 -- Python 3.7.4, pytest-5.0.1, py-1.8.0, pluggy-0.13.0
rootdir: T:\
collected 1 item

test_it.py F                                                                   [100%]

===================================== FAILURES ====================================== 
______________________________________ test_it ______________________________________

    def test_it():
>       raise AssertionError(__file__)
E       AssertionError: T:\test_it.py

test_it.py:3: AssertionError
============================= 1 failed in 0.04 seconds ==============================
  • output of pip list from the virtual environment you are using
c:\bin\Python37-32\python.exe -m pip list
Package            Version
------------------ ----------
astroid            2.3.1
atomicwrites       1.3.0
attrs              19.3.0
certifi            2019.9.11
colorama           0.4.1
importlib-metadata 0.23
isort              4.3.21
lazy-object-proxy  1.4.2
mccabe             0.6.1
more-itertools     7.2.0
packaging          19.2
pip                19.2.3
pipenv             2018.11.26
pluggy             0.13.0
py                 1.8.0
pylint             2.4.2
pyparsing          2.4.2
pytest             5.2.1
setuptools         40.8.0
six                1.12.0
typed-ast          1.4.0
virtualenv         16.7.5
virtualenv-clone   0.5.3
wcwidth            0.1.7
wrapt              1.11.2
zipp               0.6.0
  • pytest and operating system versions

Pytest 5.2.1 has this issue. The regression was introduced in pytest 5.1.0 (i.e.: it works properly in pytest 5.0.1)

OS: Windows 10

Metadata

Metadata

Assignees

No one assigned

    Labels

    platform: windowswindows platform-specific problemtype: regressionindicates a problem that was introduced in a release which was working previously

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions