Skip to main content

simple-coverage

Very basic coverage tool for educational purposes.

Installation

pip install simple-coverage

Usage

Just import the package and add the @print_coverage decorator above functions you want to inspect.

from simple_coverage.coverage import coverage

@print_coverage
def demo(x, y) -> int:
    """
    Demo function
    """
	product = x * y 
	if product < 10:
		return product * 2
	else: 
	return product

if __name__ == "__main__":
	demo(3,5)

When simply runnning the Python-file, this will create the following output:

Function: demo(3, 5)

CALLED line 9:      product = x * y
CALLED line 10:     if product < 10:
MISSED line 11:         return product * 2
IGNORE line 12:     else:
CALLED line 13:         return product

Instruction coverage: 75.0 %
Branch coverage: 50.0 %

Doctests

If you want to use it with doctests, use the meta wrapper @doctest_wrapper and the log_coverage decorator. This will create a simple-coverage.json file in the current working directory since writing into the console would collide with the doctests.

from simple_coverage.coverage import log_coverage, doctest_wrapper

@doctest_wrapper(log_coverage)
def demo(x,y) -> int:
	...

Look at the demo.py file for reference. To start the doctest use pytest as usual.

pytest --doctest-modules demo.py

Afterwards you can create the report:

python3 -m simple_coverage.report

Note that all runs will be saved for the next report. To start over and delete to report run:

python3 -m simple_coverage.clean

Metadata

Release files for simple-coverage 0.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for simple-coverage 0.3.2
File Size Uploaded Provenance Actions
simple_coverage-0.3.2.tar.gz 5.8 kB Without provenance Details for simple_coverage-0.3.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for simple-coverage 0.3.2
File Interpreter ABI Platform Actions
simple_coverage-0.3.2-py3-none-any.whl Python 3 none any Details for simple_coverage-0.3.2-py3-none-any.whl

Total release size: 12.3 kB

Release files / simple_coverage-0.3.2.tar.gz

Download URL simple_coverage-0.3.2.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
30fca6d691f0f40b089a08c3fe5061f85369e3a1221318360e5adc2abe0a86d5
BLAKE2b-256 checksum
How to use checksums
43570865a9ad673de1eef3c622c7cc9bc2a8a22dbd5b949048fe4750605f071e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

Release files / simple_coverage-0.3.2-py3-none-any.whl

Download URL simple_coverage-0.3.2-py3-none-any.whl
Size 6.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
96680133d720b679646e49676922c92978cf4516373dfa1d8e0823e61d7234bc
BLAKE2b-256 checksum
How to use checksums
717915696f55d5fc45f27bc0433a40d3b8a2ed712e96431b790b887989eac140
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

Security for simple-coverage 0.3.2

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page