问题描述
我最近开始使用 poetry
来管理项目依赖项,
而不是使用 requirements.txt
和 test-requirements.txt
和
pip
。
自从进行更改后,我无法进行覆盖测试
正确。在这两种情况下,我都使用 tox
来驱动测试(并且我
安装了 tox-poetry
扩展)。
我的 tox.ini
目前看起来像这样:
[tox]
isolated_build = True
envlist = pep8,unit
[testenv]
whitelist_externals = poetry
[testenv:venv]
commands = {posargs}
[testenv:pep8]
commands =
poetry run flake8 {posargs:symtool}
[testenv:unit]
commands =
poetry run pytest --cov=symtool {posargs} tests/unit
以前是这样的:
[tox]
envlist = pep8,unit
[testenv]
usedevelop = True
install_command = pip install -U {opts} {packages}
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
[testenv:venv]
commands = {posargs}
[testenv:pep8]
commands =
flake8 {posargs:symtool}
[testenv:unit]
commands =
pytest --cov=symtool {posargs} tests/unit
自从更改为 poetry
后,当我运行时,例如tox -e unit
,我明白了:
unit run-test: commands[0] | poetry run pytest --cov=symtool tests/unit
===================================== test session starts =====================================
platform linux -- Python 3.9.1,pytest-6.2.2,py-1.10.0,pluggy-0.13.1
cachedir: .tox/unit/.pytest_cache
rootdir: /home/lars/projects/symtool,configfile: tox.ini
plugins: cov-2.11.1
collected 14 items
tests/unit/test_disasm.py ..... [ 35%]
tests/unit/test_symtool.py ......... [100%]r
Coverage.py warning: No data was collected. (no-data-collected)
我正在尝试找出 no-data-collected
问题。根据
pytest --help
,--cov
参数设置路径或包
名称:
--cov=[SOURCE] Path or package name to measure during execution
存储库的根目录(在上面的输出中是 rootdir
来自 tox
) 看起来像这样:
asm
pyproject.toml
README.md
reference
symtool
tests
tox.ini
那里肯定有一个包含软件包的 symtool
目录。
即使测试以某种方式不在项目根目录中运行
目录,symtool
包安装在测试环境中,
单元测试实际上正在通过这一事实证明了这一点(所有
其中包括 import symtool
的一些变体)。
我如何才能重新获得保障?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)