Closed Sheila-nk closed 8 months ago
For completeness, here's the one way to run doctests and suppress these collection errors:
$ python dev.py shell
<... new shell opens>
$ PY_IGNORE_IMPORTMISMATCH=1 pytest --doctest-modules --pyargs scipy -x --ignore=/home/br/repos/scipy/scipy/build-install/lib/python3.10/site-packages/scipy/_lib --ignore=/home/br/repos/scipy/scipy/build-install/lib/python3.10/site-packages/scipy/interpolate/_interpnd_info.py
(this ignores the whole of scipy/_lib
for simplicity)
This seems to have been a combination of several things:
build-install
. Solution: only run on build-install
.scipy.signal.__init__
imports names from scipy.signal._signaltools
etc). Solution: skip anything with a leading underscore in the full qualified name (https://github.com/ev-br/scpdt/commit/de5e3f1d184a4d4c7c526bef37f3e6711f4035c2)So this issue seems to have been fixed, let's close as completed. Thanks Sheila!
On running the command
pytest --doctest-modules scipy/constants -v
on the Scipy shell, you get the following error:The problem seems to be with pytest's import mode:
prepend
which basically prepends the directory containing test files to the python path leading to conflicts with modules that have the same name but exist in different locations. You can find more information here: choosing an import modeThe issue occurs in Scipy because the build system copies the python source files to
build-install
.Currently, to overcome this issue, you can either:
build-install
importlib
You might also come across the following error:
This seems to be a pytest issue: https://github.com/pytest-dev/pytest/issues/9567#issuecomment-1117538794
A temporary fix is setting the environment variable:
PY_IGNORE_IMPORTMISMATCH=1