You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PyTest fails even though Python module is in PYTHONPATH.
==================================================================================== test session starts =====================================================================================
platform freebsd13 -- Python 3.9.13, pytest-7.1.2, pluggy-1.0.0 -- /usr/local/bin/python3.9
cachedir: .pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/disk-samsung/freebsd-ports/textproc/py-jarowinkler/work-py39/jarowinkler-1.0.5/.hypothesis/examples')
rootdir: /disk-samsung/freebsd-ports/textproc/py-jarowinkler/work-py39/jarowinkler-1.0.5
plugins: forked-1.4.0, rerunfailures-10.1, hypothesis-6.47.3, xdist-2.5.0, cov-2.9.0
collected 0 items / 2 errors
=========================================================================================== ERRORS ===========================================================================================
_________________________________________________________________________ ERROR collecting tests/test_JaroWinkler.py _________________________________________________________________________
ImportError while importing test module '/disk-samsung/freebsd-ports/textproc/py-jarowinkler/work-py39/jarowinkler-1.0.5/tests/test_JaroWinkler.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/local/lib/python3.9/importlib/__init__.py:127: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
tests/test_JaroWinkler.py:7: in <module>
from jarowinkler import jarowinkler_similarity
jarowinkler/__init__.py:5: in <module>
from ._initialize import *
E ModuleNotFoundError: No module named 'jarowinkler._initialize'
_________________________________________________________________________ ERROR collecting tests/test_hypothesis.py __________________________________________________________________________
ImportError while importing test module '/disk-samsung/freebsd-ports/textproc/py-jarowinkler/work-py39/jarowinkler-1.0.5/tests/test_hypothesis.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/local/lib/python3.9/importlib/__init__.py:127: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
tests/test_hypothesis.py:5: in <module>
from jarowinkler import jarowinkler_similarity
jarowinkler/__init__.py:5: in <module>
from ._initialize import *
E ModuleNotFoundError: No module named 'jarowinkler._initialize'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
===================================================================================== 2 errors in 1.21s ======================================================================================
*** Error code 2
The text was updated successfully, but these errors were encountered:
This issue occurs when a relative import is resolved to the local jarowinkler directory instead of the installed package. This local directory does not include the _initialize.so, since this is built as part of the installation. I just tried this locally and it appears:
python3 -m pytest
and
python3 -m pytest tests
picks up the wrong import path while
pytest
and
cd tests
python3 -m pytest
work fine. Not sure why this leads to a different import behavior though.
Ah it is described here: https://docs.pytest.org/en/7.1.x/explanation/pythonpath.html#pytest-vs-python-m-pytest
Appears you have to move the sources from /jarowinkler into /src/jarowinkler to prevent this. Not a big fan of this ugliness, but will change it in the next release to please the tools 🤷♂️
I will release a patch version with the change tomorrow
PyTest fails even though Python module is in PYTHONPATH.
The text was updated successfully, but these errors were encountered: