samedi 29 septembre 2018

Python Coverage - not covering function contents, just definition

I am using coverage.py to test my code coverage. My tests are passing, however, when I call

coverage run -- [script].py -m [test_script].py

and generate a report it indicates that

<line hits="1" number="5"/>
<line hits="0" number="6"/>
<line hits="0" number="7"/>
<line hits="0" number="8"/>

Where line 5,6,7 and 8 are as follows:

def __init__(self, data):
        self.left = None
        self.right = None
        self.data = data

For another example:

My test code:

def test_arb():
assert tree.inc(3) == 4

the function

def inc(x):
    return x+1

and the result on the report

<line hits="1" number="48"/>
<line hits="0" number="49"/>

I've spent days researching this and can't seem to find a straightforward answer. Would anyone be able to help? It may be an obvious fix but I am a beginner at Python and testing.

Aucun commentaire:

Enregistrer un commentaire