Skip to main content

Creates a set of all lines that have no test coverage in the current git diff

Project description

missing_diff_lines

Run missing_diff_lines() after you ran coverage.py in a git-repo, e.g. with coverage run -m unittest discover. It will output a set with tuples in the form (filename, line-number) for every line in the current diff, that has no test that covers it.

Example

Say you have this code in calc.py and no tests yet:

def mul(a, b):
    return a * b

You add some more cod:

def mul(a, b):
    return a * b

def div(a, b):
    if b == 0:
        return 0
    return a / b

As well as a test-suite:

class TestDiv(TestCase):

    def test_simple_div(self):
        self.assertEqual(3, div(9, 3))

Note, that the branch b == 0 is not covered. And indeed. if you run:

$ coverage run -m unittest discover && python3 report.py

Where this is the content of report.py:

from missing_diff_lines import missing_diff_lines
from pprint import pprint

print(missing_diff_lines())

You get

{('calc.py', 6)}

Which is correct, as this line is not covered. But note, that the not covered line 2 is not in the current diff and thus is not reported. This is the very purpose of this package.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

missing_diff_lines-0.0.4.tar.gz (7.5 kB view hashes)

Uploaded Source

Built Distribution

missing_diff_lines-0.0.4-py3-none-any.whl (7.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page