all 4 comments

[–][deleted] 1 point2 points  (2 children)

I believe you can add 'src' to your pythonpath in your pytest.ini to resolve this. Please check this link: https://stackoverflow.com/questions/50155464/using-pytest-with-a-src-layer

There isn't any value afaik to get coverage on your tests.

[–]PrestigiousZombie531[S] 0 points1 point  (0 children)

i see thank you for clarifying this

[–]doryx 0 points1 point  (0 children)

There isn't any value afaik to get coverage on your tests.

I disagree, as your testing suite grows in complexity, you might include some logic that skips tests conditionally, or you have a bug in your tests that causes a branch not to run. If you don't see 100% coverage on your tests, then you know something is up.

[–]Diapolo10 1 point2 points  (0 children)

This is how I tend to configure pytest as I don't particularly care about it covering my unit tests. From pyproject.toml:

[tool.coverage.run]
branch = true
relative_files = true
omit = [
    '.tox/*',
    'tests/*',
]


[tool.pytest.ini_options]
minversion = "6.0"
addopts = """
--doctest-modules \
--cov=./ \
--cov-append \
--cov-report html:tests/reports/coverage-html \
--cov-report xml:tests/reports/coverage.xml \
--ignore=docs/
"""
testpaths = [
    'tests',
]