1

我正在使用 tox 使用 tox -p(并行运行)在不同的环境上运行测试,但是在为所有测试生成覆盖率报告时遇到问题。

毒物.ini:

[tox]
envlist = env1,ev2,report
skipsdist=True

[base]
deps = pytest


[testenv:env1]
deps = custom-package-1
       {[base]deps}
commands = pytest --cov-append tests/flows/test_1.py

[testenv:env2]
deps = custom-package-2
       {[base]deps}
commands = pytest --cov-append tests/flows/test_2.py

[testenv:report]
deps = coverage[toml]
commands = coverage report
depends = env1,env2
parallel_show_output = true

pyproject.toml 覆盖部分:

[tool.coverage.report]
fail_under = 100
show_missing = true
exclude_lines = [
    'pragma: no cover',
    '\.\.\.',
    'if TYPE_CHECKING:',
    "if __name__ == '__main__':",
]

错误:

No source for code: '/Users/my_user/projects/my_proect/flows/__init__.py'.

有人可以告诉我提供的配置有什么问题吗?

4

1 回答 1

1

您需要重新映射源文件,请参阅https://coverage.readthedocs.io/en/6.2/config.html?highlight=paths#paths和例如https://github.com/tox-dev/tox/blob/主/tox.ini#L136-L143

于 2021-12-10T18:22:34.037 回答