Repository navigation
Still getting ImportPathMismatchError when using tox and fixtures conftest.py
#10109
|
I am observing a weird situation that makes me question my pytest setup. So far my tests were working well, but today I decided to add some fixtures to There are no This is probably similar to what @matthewfeickert observed in scikit-hep/pyhf#1467 and I solved it in the same way: removing Basically, my question is: is this a bug? A feature? Am I doing anything wrong by removing |
Replies: 1 comment
|
Hi @astrojuanlu The mismatch is real: pytest is ending up with two different copies of Your I would not use The preferred fix is to make each pytest invocation use one package location consistently:
So removing Please mark this answer as accepted if it helped, thank you. |
Hi @astrojuanlu
The mismatch is real: pytest is ending up with two different copies of
poliastrounder the same import name.Your
conftest.pyimports the installed copy from the tox environment, while collectingsrcfor doctests causes pytest/pytest-doctestplus to encounter the source-tree copy. Once one copy has already been imported, pytest detects that the module being collected comes from a different path and raisesImportPathMismatchError.I would not use
PY_IGNORE_IMPORTMISMATCH=1as the normal solution. It disables the safety check and can hide the fact that you are testing/importing a different copy than intended.The preferred fix is to make each pytest invocation use one package…