Coverage Report using pytest-cov
#513
Answered
by
sinisaos
billsioros
asked this question in
Q&A
-
Hello 👋🏽 everyone, I'm trying to create a coverage report for my application and I noticed that my controllers report a 0% coverage even though I use the [tool.pytest.ini_options]
pythonpath = [ "src" ]
asyncio_default_fixture_loop_scope = "session"
addopts = "-vv --color=yes --cov=api --cov-report=term-missing --cov-report=html"
log_cli = false
log_cli_date_format = "%Y-%m-%d %H:%M:%S"
log_cli_format = "%(asctime)s %(levelname)s %(message)s"
log_cli_level = "INFO"
python_files = "test_*.py"
python_functions = "test_*"
testpaths = "tests"
markers = [
"unit: Unit tests",
"integration: Integration tests",
"skip: Skip tests",
"xfail: Expected to fail tests",
"asyncio: Mark test to be run with pytest-asyncio",
]
[tool.coverage.paths]
source = [ "src" ]
[tool.coverage.run]
branch = true
source = [ "api" ]
concurrency = [ "greenlet", "thread" ]
[tool.coverage.report] Could you please assist me? Thanks! 😋 |
Beta Was this translation helpful? Give feedback.
Answered by
sinisaos
Oct 9, 2024
Replies: 1 comment 1 reply
-
@billsioros I'm tried to test a simple .
├── htmlcov
├── __pycache__
├── pyproject.toml
├── src
│ ├── __init__.py
│ └── server.py
└── tests
├── conftest.py
├── __init__.py
└── test_app.py I modified your [tool.pytest.ini_options]
pythonpath = ["src"]
asyncio_default_fixture_loop_scope = "session"
log_cli = false
log_cli_date_format = "%Y-%m-%d %H:%M:%S"
log_cli_format = "%(asctime)s %(levelname)s %(message)s"
log_cli_level = "INFO"
python_files = "test_*.py"
python_functions = "test_*"
testpaths = "tests"
markers = [
"unit: Unit tests",
"integration: Integration tests",
"skip: Skip tests",
"xfail: Expected to fail tests",
"asyncio: Mark test to be run with pytest-asyncio",
]
[tool.coverage.report]
fail_under = 90
[tool.coverage.run]
branch = true
source = ["src"]
disable_warnings = ['no-data-collected']
command_line = "-m pytest -vv --color=yes --cov=src --cov-report=term-missing --cov-report=html" You need to |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
billsioros
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@billsioros I'm tried to test a simple
Hello World
application. Here is the projecttree
.. ├── htmlcov ├── __pycache__ ├── pyproject.toml ├── src │ ├── __init__.py │ └── server.py └── tests ├── conftest.py ├── __init__.py └── test_app.py
I modified your
pyproject.toml
like this