dytyniak
dytyniak

Reputation: 394

How to configure coverage with tox?

I am using tox to run tests on different envs using tox -p(run in parallel), but have a problem with coverage report generation for all tests.

tox.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 coverage section:

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

Error:

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

Can someone tell me what is wrong with provided configuration?

Upvotes: 6

Views: 5238

Answers (1)

Related Questions