-
Notifications
You must be signed in to change notification settings - Fork 231
Coverage both says its 100% and 0% when no code lines are found, fails #641
Copy link
Copy link
Closed
Description
Summary
I've created a project and for now was working on CI, so there is no actual code in the "library". Coverage is set to fail under 60, I have a single unit test that imports my package.
Running coverage check boths says its 100% and passed, and then that it didn't reach 60% and fails.
Expected vs actual result
(models-py3.11) ~/b/models (f/remove_cli|●2✚2)[1] $ poe test (base) 09:57:41
Poe => pytest
============================================================== test session starts ===============================================================
platform darwin -- Python 3.11.5, pytest-8.1.1, pluggy-1.4.0
rootdir: /Users/kai7rng/bosch/models
configfile: pyproject.toml
testpaths: tests
plugins: cov-5.0.0, html-4.1.1, metadata-3.1.1
collecting ... imported the library
collected 1 item
tests/test_library.py . [100%]
------------------------------------------- generated xml file: /Users/kai7rng/bosch/models/pytest.xml -------------------------------------------
---------- coverage: platform darwin, python 3.11.5-final-0 ----------
Name Stmts Miss Branch BrPart Cover Missing
----------------------------------------------------------------------------------
prediction_model_library/__init__.py 1 0 0 0 100%
----------------------------------------------------------------------------------
TOTAL 1 0 0 0 100%
Required test coverage of 60.0% reached. Total coverage: 100.00%
--------------------------- Generated html report: file:///Users/kai7rng/bosch/models/docs/exported/tests/report.html ----------------------------
=============================================================== 1 passed in 0.09s ================================================================
Poe => coverage xml
Wrote XML report to coverage.xml
Poe => coverage html --directory docs/exported/coverage
Wrote HTML report to docs/exported/coverage/index.html
Poe => mv docs/exported/coverage/index.html docs/exported/coverage/report.html
Poe => coverage report
Name Stmts Miss Branch BrPart Cover Missing
----------------------------------------------------------------------------------
prediction_model_library/__init__.py 1 0 0 0 100%
----------------------------------------------------------------------------------
TOTAL 1 0 0 0 100%
(models-py3.11) ~/b/models (f/remove_cli|●2✚2)$
Versions
python 3.11, all latest as of April 2024
Config
# Tools config
[tool.coverage.report]
fail_under = 60
show_missing = true
skip_empty = true
[tool.coverage.run]
branch = true
source = ["library"]
[tool.pytest.ini_options]
addopts = [
"--capture=tee-sys",
"--cov",
"--cov-config=pyproject.toml",
"--full-trace",
"--html=docs/exported/tests/report.html",
"--junit-xml=pytest.xml",
"--self-contained-html",
"--showlocals",
"-ra",
]
testpaths = ["tests"]
[tool.poe.tasks.test]
sequence = [
{ cmd = "pytest" },
{ cmd = "coverage xml" },
{ cmd = "coverage html --directory docs/exported/coverage" },
{ shell = "mv docs/exported/coverage/index.html docs/exported/coverage/report.html" },
{ cmd = "coverage report" },
]
Code
"library" contains __init__.py with a docstring and nothing else.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels