pytest-dev / py

Python development support library (note: maintenance only)
MIT License
67 stars 106 forks source link

Normalise path before comparing on windows #225

Open patstew opened 4 years ago

patstew commented 4 years ago

Without this change I get pytest errors on MSYS2 like this:

=================================== ERRORS ====================================
_______________ ERROR collecting test_x.py ________________
import file mismatch:
imported module 'f.test_x' has this __file__ attribute:
  C:/path/to\f\test_x.py
which is not the same as the test file we want to collect:
  C:/path/to/f/test_x.py
HINT: remove __pycache__ / .pyc files and/or use a unique basename for your test file modules
!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!
=========================== 1 error in 0.20 seconds ===========================

Removing __pycache__ or using PYTHONDONTWRITEBYTECODE=1 doesn't help. This seems to be the same problem as #58 was trying to fix. I've moved it to __eq__ as suggested in the original PR on bitbucket.

patstew commented 4 years ago

I don't think that test failure is due to this PR

blueyed commented 4 years ago

@patstew Can you add a test for it, please? (and rebase it then) Likely good to use the example from how pytest triggers it.

bluetech commented 4 years ago

Note: this semantically conflicts with #243. If #243 is merged, then this PR will need to also update __hash__.