Skip to content

Commit

Permalink
Branch coverage and set branch cov in pytest.ini
Browse files Browse the repository at this point in the history
  • Loading branch information
scarpent committed Jul 15, 2018
1 parent cb7dfac commit 2431b3f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
9 changes: 5 additions & 4 deletions ledgerbil/reconciler.py
Expand Up @@ -462,8 +462,10 @@ def finish_balancing(self):
return

for thing in self.open_transactions:
if thing.is_pending():
thing.set_cleared()
# todo: removing previous check for the sake of branch coverage:
# thing.is_pending()
# remove this todo if things don't suffer for it...
thing.set_cleared()

self.previous_balance = self.ending_balance
self.previous_date = date.today()
Expand Down Expand Up @@ -596,8 +598,7 @@ def reconciled_status():

for balance_line in balance_lines:
ledger = get_account_balance_generic(balance_line)
if ledger:
accounts[ledger.account].ledger_balance = ledger.amount
accounts[ledger.account].ledger_balance = ledger.amount

reconciled_status_report(accounts)

Expand Down
22 changes: 22 additions & 0 deletions ledgerbil/tests/test_reconciler.py
Expand Up @@ -405,6 +405,7 @@ def test_get_rec_account_matched_when_match_in_either_file():

assert reconciler.get_rec_account_matched() == 'a: 401k: james bonds idx'

# reverse order of reconciler files
with FileTester.temp_input(ledgerfile_data) as tempfilename:
with FileTester.temp_input(ledgerfile2_data) as tempfilename2:
reconciler = Reconciler([
Expand All @@ -415,6 +416,27 @@ def test_get_rec_account_matched_when_match_in_either_file():
assert reconciler.get_rec_account_matched() == 'a: 401k: james bonds idx'


def test_get_rec_account_matched_when_match_in_neither_file():
ledgerfile_data = dedent('''
2017/11/28 zombie investments
a: 401k: stock idx 12.357 qwrty @ $20.05
i: investment: adjustment
''')
ledgerfile2_data = dedent('''
2017/12/28 zombie investments
a: 401k: james bonds idx 45.678 qwrty @ $31.11
i: investment: adjustment
''')

with FileTester.temp_input(ledgerfile_data) as tempfilename:
with FileTester.temp_input(ledgerfile2_data) as tempfilename2:
with pytest.raises(StopIteration):
Reconciler([
LedgerFile(tempfilename, 'goldfinger'),
LedgerFile(tempfilename2, 'goldfinger'),
])


def test_init_things():
with FileTester.temp_input(testdata) as tempfilename:
ledgerfile = LedgerFile(tempfilename, 'cash')
Expand Down
2 changes: 1 addition & 1 deletion pytest.ini
@@ -1,3 +1,3 @@
[pytest]
norecursedirs = .* __pycache__ ve
addopts = --cov . --cov-report term-missing -q --color=yes --no-cov-on-fail
addopts = --cov . --cov-report term-missing -q --color=yes --no-cov-on-fail --cov-branch

0 comments on commit 2431b3f

Please sign in to comment.