I am trying to achieve a 100% coverage for a basic python module.
I use Ned Batchelder's coverage.py module to test it.
1 class account(object):
2 def __init__(self, initial_balance=0):
3 self.balance = initial_balance
4 def add_one(self):
5 self.balance = self.balance + 1
These are the tests.
class TestAccount(unittest.TestCase):
def test_create_edit_account(self):
a = account1.account()
a.add_one()
Here is what the coverage report I get.
COVERAGE REPORT =
Name Stmts Miss Cover Missing
-----------------------------------------------------
__init__ 1 1 0% 1
account1 5 3 40% 1-2, 4
account2 7 7 0% 1-7
As we can see, the lines 1-2 and 4 are not covered which are the defintions.
The rest of the lines are executed.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…