.coveragerc 无法找到我想省略的文件
.coveragerc unable to locate files I want omitted
我正在使用 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
我认为这已经足够了,但如果您需要更多,请告诉我 output/information。
我该如何解决这个问题?
将 .coveragerc 更改为:
[run]
omit =
*/package/__main__.py
*/package/__init__.py
我正在使用 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
我认为这已经足够了,但如果您需要更多,请告诉我 output/information。
我该如何解决这个问题?
将 .coveragerc 更改为:
[run]
omit =
*/package/__main__.py
*/package/__init__.py