pytest fails to load pooch in developer setup
See original GitHub issueDescribe the bug
The following Traceback is obtained when attempting to run any form of pytest, such as pytest mne/tests
from the project root directory, when the current main
is cloned on my system with the recommended YML-based environment creation and an editable pip install, with all requirements satisfied.
ImportError while loading conftest '/Users/tevesjb/repositories/mne-python/mne/conftest.py'.
mne/conftest.py:31: in <module>
test_path = testing.data_path(download=False)
mne/datasets/testing/_testing.py:22: in data_path
return _data_path(path=path, force_update=force_update,
mne/datasets/utils.py:213: in _data_path
pooch = _soft_import('pooch', 'dataset downloading', strict=True)
mne/utils/check.py:273: in _soft_import
raise RuntimeError(f'For {purpose} to work, the {name} module is '
E RuntimeError: For dataset downloading to work, the pooch module is needed, but it could not be imported.
Steps to reproduce
pooch
is available in the environment that the test is being run from:
>>> import pooch
>>> pooch.__version__
'v1.5.1'
Just as bizarrely, if I use the same facility as check.py
, the load is successful:
>>> import mne
>>> from mne.utils.check import _soft_import
>>> p = _soft_import('pooch', 'dataset downloading', strict=True)
>>> print(p)
<module 'pooch' from '/Users/tevesjb/miniconda3/envs/mne-dev/lib/python3.9/site-packages/pooch/__init__.py'>
However, running pytest triggers the above RuntimeError and traceback, regardless of which test (presumably because the error occurs in test configuration).
Expected results
The tests at least run, even if they fail.
Actual results
The test configuration fails, so I can’t even use the debugger via pytest --trace
.
Additional information
Platform: macOS-10.15.7-x86_64-i386-64bit
Python: 3.9.7 | packaged by conda-forge | (default, Sep 23 2021, 07:31:23) [Clang 11.1.0 ]
Executable: /Users/tevesjb/miniconda3/envs/mne-dev/bin/python
CPU: i386: 8 cores
Memory: 16.0 GB
mne: 0.24.dev0
numpy: 1.21.2 {blas=NO_ATLAS_INFO, lapack=lapack}
scipy: 1.7.0
matplotlib: 3.4.2 {backend=MacOSX}
sklearn: 0.24.2
numba: 0.53.1
nibabel: 3.2.1
nilearn: 0.8.0
dipy: 1.4.1
cupy: Not found
pandas: 1.3.0
mayavi: 4.7.2
pyvista: 0.32.1 {pyvistaqt=0.5.0, OpenGL 4.1 INTEL-14.7.18 via Intel(R) Iris(TM) Plus Graphics OpenGL Engine}
vtk: 9.0.1
PyQt5: 5.12.3
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
pytest cannot import module while python can - Stack Overflow
The solution was to install pytest in the virtual environment. (In case your shell hashes executables, as Bash does, use hash -r ,...
Read more >Cannot install for development - dependencies ... - GitHub
I'm trying to install for development as described here https://hvplot.holoviz.org/developer_guide/index.html#conda-environments.
Read more >Installing — Pooch v0.5.2 - Fatiando a Terra
We recommend using the Anaconda Python distribution to ensure you have all dependencies installed and the conda package manager available.
Read more >Getting Started Unit Testing with Pytest - Towards Data Science
pip install pytest ... import project # test basic functionality ... Not only does pytest make it clear that our test failed, ...
Read more >Pytest Unit Testing Tutorial • How to test your Python code
Chapters 00:00 Introduction 02:45 Install Pytest and setup the ... "assert") 11:24 How to test that an Error is raised 18:30 How to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
closing because already fixed
You can just add it to the tuple I think, and update toward the top of the
Enhancements
section ofdoc/changes/latest.inc
(with the special “new contributor” substitution + bolding), and alsodoc/changes/names.inc
to add your name!