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
=> What are the right parameters for pytest_func_cov and what --import-mode should I use for pytest?
I tried pytest --func_cov=src --func_cov_report=term-missing test but get a No module named 'foo' error.
"Development tools should ensure that they support the src layout cleanly - they can obviously also support the non-src layout, but we should be clear that in order to be recommended in the PyPA guidelines, a tool must be capable of supporting the src layout."
in combination with following pyproject.toml settings for pytest:
[tool.pytest.ini_options]
# Also see
# https://docs.pytest.org/en/7.1.x/customize.html#pyproject-toml
# https://pytest-cov.readthedocs.io/en/latest/config.html
# If you want to see console output from tests, include -s flag
addopts = [
# !! do not include --cov option here because it would destroy PyCharm debug feature !!
# Also see https://stackoverflow.com/questions/40718760/unable-to-debug-in-pycharm-with-pytest
'--junitxml=report.xml',
'--import-mode=importlib',
]
pythonpath = 'src'
testpaths = 'test'
My project has following structure using a src folder
=> What are the right parameters for pytest_func_cov and what --import-mode should I use for pytest?
I tried
pytest --func_cov=src --func_cov_report=term-missing test
but get aNo module named 'foo'
error."Development tools should ensure that they support the src layout cleanly - they can obviously also support the non-src layout, but we should be clear that in order to be recommended in the PyPA guidelines, a tool must be capable of supporting the src layout."
pypa/packaging.python.org#320 (comment)
As kind of a workaround, some interim solution might be to add some extra folders to the PYTHON_PATH.
a) Maybe pytest_func_cov could support some init-hook like pylint.
b) Or support a test_setup.py file under src, initialiting the path:
The text was updated successfully, but these errors were encountered: