我正在使用tox
和pytest
和pytest-cov
插件自动运行测试。但是,我正在获取.coveragerc
中遗漏的文件的覆盖率报告:
(env) alex@smartalex-pc:~/.repos/codelib/github/project$ tox
[...]
../../../tests/test_module1.py::test_func PASSED [ 3%]
[...]
../../../tests/test_module2.py::test_func PASSED [100%]
----------- coverage: platform linux, python 3.6.7-final-0 -----------
Name Stmts Miss Cover
--------------------------------------------------------------------------------------------------------------------------
/home/alex/.repos/codelib/github/project/.tox/py36/lib/python3.6/site-packages/package/__init__.py 0 0 100%
/home/alex/.repos/codelib/github/project/.tox/py36/lib/python3.6/site-packages/package/__main__.py 2 2 0%
/home/alex/.repos/codelib/github/project/.tox/py36/lib/python3.6/site-packages/package/application.py 40 0 100%
/home/alex/.repos/codelib/github/project/.tox/py36/lib/python3.6/site-packages/package/core.py 73 0 100%
/home/alex/.repos/codelib/github/project/.tox/py36/lib/python3.6/site-packages/package/user_interface.py 45 0 100%
--------------------------------------------------------------------------------------------------------------------------
TOTAL 160 2 99%
似乎tox
没有使用我的.coveragerc
。我尝试使用--cov-config={toxinidir}/.coveragerc
明确指定配置文件,但再次得到相同的结果。
简化的项目结构:
package/
__init__.py
__main__.py
application.py
core.py
user_interface.py
tests/
test_module1.py
test_module2.py
.coveragerc
pytest.ini
setup.py
tox.ini
这是我的tox.ini
:
[tox]
envlist = py36
[testenv]
changedir = {envtmpdir}
deps =
trio
-r dev-requirements.txt
commands =
pytest -v {toxinidir}/tests --cov=package --cov-config={toxinidir}/.coveragerc
这是我的.coveragerc
:
[run]
omit =
package/__main__.py
package/__init__.py
这是我的pytest.ini
:
[pytest]
trio_mode = true
我认为这就足够了,但是如果您需要更多的输出/信息,请告诉我。
我该如何解决这个问题?
答案 0 :(得分:1)
将.coveragerc更改为:
getUserHomeDir() {
return 'data/extensions-data';
}