Closed as not planned
Description
- Bitbucket: https://bitbucket.org/pytest-dev/py/issue/58
- Originally reported by: @vladipus
- Originally created at: 2015-02-27T19:02:57.723
The 'LocalPath.samefile' method should normalize the path on MS Windows, since it can contain back slahes.
Otherwise, I'm getting the following error in (my currently loved of which I'm thankful to you) pytest system:
Traceback (most recent call last):
File "C:\msys64\mingw64\lib\python2.7\site-packages/_pytest/config.py", line 543, in importconftest
mod = conftestpath.pyimport()
File "C:\msys64\mingw64\lib\python2.7\site-packages\py/_path/local.py", line 664, in pyimport
raise self.ImportMismatchError(modname, modfile, self)
ImportMismatchError: ('conftest', 'C:\\secret-project\\tests/conftest.py', local('C:\\secret-project\\tests\\conftest.py'))
Suggested fix:
def samefile(self, other):
""" return True if 'other' references the same file as 'self'.
"""
other = getattr(other, "strpath", other)
if not isabs(other):
other = abspath(other)
if self == other:
return True
if iswin32:
# Convert possible forward slashes to back.
if self == normpath(other):
return True
else:
return False # there is no samefile
return py.error.checked_call(
os.path.samefile, self.strpath, other)