fun-coverage
fun-coverage is a tool to extract function coverage from the statement (= line) coverage of coverage.py.
Installation
The simplest way to install fun-coverage is with pip:
pip install fun-coverage
Getting started
After installing the package, a fun-coverage command will be available.
You need to run coverage.py first. For example, if you're using it through pytest-cov:
pytest --cov=<my_module> <my_module_tests>
Once this is done, simply run:
fun-coverage
This will print a text report similar to the one of coverage.py, but for functions. The report will include the line numbers of the missed functions.
For example, this is the output of fun-coverage run on its example test suite (as a preliminary step of its actual test suite):
Name Funcs Miss Cover Missing
--------------------------------------------------------------------------------------------------------------
tests/example_test_suite/src/__init__.py 0 0 100%
tests/example_test_suite/src/async_function.py 1 0 100%
tests/example_test_suite/src/covered_function_with_partially_covered_lines.py 1 0 100%
tests/example_test_suite/src/docstring_only_function.py 1 0 100%
tests/example_test_suite/src/excluded_function.py 0 0 100%
tests/example_test_suite/src/methods.py 2 2 0% 6, 9
tests/example_test_suite/src/non_covered_function.py 1 1 0% 1
--------------------------------------------------------------------------------------------------------------
TOTAL 6 3 50%
How it works
fun-coverage looks for functions and methods in the source code files concerned by a previous round of statement coverage measurement, then marks them as hit if and only if their first statement has been hit.
Specifically, this starts from the .coverage file left by coverage.py. This is configurable with the --cov-file flag.
Command-line options
usage: fun-coverage [--cov-file COV_FILE] [--cov-fail-under MIN]
--cov-file COV_FILE Which coverage file to analyze (default .coverage in the current directory)
--cov-fail-under MIN Fail if the total coverage is strictly less than MIN (a percentage between 0 and 100)
Excluding code from fun-coverage
If the line containing the def or async def statement for a function is excluded from coverage.py, then fun-coverage ignores that entire function.
Compatibility
fun-coverage has been tested with coverage==6.4, and pytest-cov==3.0.0.
Development
This section only applies if you wish to contribute to the project.
pre-commit
This project uses pre-commit. Please install it, then activate it to run automatically on git commit:
pre-commit install
Tests
Run the test suite with:
make test
Metadata
Release files for fun-coverage 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fun_coverage-0.2.0.tar.gz | 6.4 kB | Without provenance | Details for fun_coverage-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fun_coverage-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for fun_coverage-0.2.0-py3-none-any.whl |
Total release size: 13.2 kB
Release files / fun_coverage-0.2.0.tar.gz
| Download URL | fun_coverage-0.2.0.tar.gz |
|---|---|
| Size | 6.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5a77f8ca857bf991f9d4b76504ccee93aecea89153490f31d5d8c1c1d22e3e24
|
|
BLAKE2b-256 checksum How to use checksums |
cf7bac57f35158c1060a808b5c120238936508b17d8aec9e2706dc92e997191c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.7
|
Release files / fun_coverage-0.2.0-py3-none-any.whl
| Download URL | fun_coverage-0.2.0-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
292d355a974f8f500b29dbe02a7b4a591516c670cb3a0c9cd68fe034978bddad
|
|
BLAKE2b-256 checksum How to use checksums |
ea7d707a65cb26a6ac7b905b615d6c4d973826e39b985156488f922bcc9745c6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.7
|
Security for fun-coverage 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.