Skip to content

Commit b79005b

Browse files
committed
New JSON info should be reported on individual files also.
1 parent b1194fb commit b79005b

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

CHANGES.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ want to know what's different in 5.0 since 4.5.x, see :ref:`whatsnew5x`.
2424
Unreleased
2525
----------
2626

27+
- The JSON report now includes counts of covered and missing branches. Thanks,
28+
Salvatore Zagaria.
29+
2730
- On Python 3.8, try-finally-return reported wrong branch coverage with
2831
decorated async functions (`issue 946`_). This is now fixed. Thanks, Kjell
2932
Braden.

coverage/jsonreport.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,7 @@ def report_one_file(self, coverage_data, analysis):
9797
reported_file['summary'].update({
9898
'num_branches': nums.n_branches,
9999
'num_partial_branches': nums.n_partial_branches,
100+
'covered_branches': nums.n_executed_branches,
101+
'missing_branches': nums.n_missing_branches,
100102
})
101103
return reported_file

tests/test_json.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ def test_branch_coverage(self):
5454
'num_branches': 2,
5555
'excluded_lines': 0,
5656
'num_partial_branches': 1,
57-
'percent_covered': 60.0
57+
'covered_branches': 1,
58+
'missing_branches': 1,
59+
'percent_covered': 60.0,
5860
}
5961
}
6062
},
@@ -67,7 +69,7 @@ def test_branch_coverage(self):
6769
'num_partial_branches': 1,
6870
'percent_covered': 60.0,
6971
'covered_branches': 1,
70-
'missing_branches': 1
72+
'missing_branches': 1,
7173
}
7274
}
7375
self._assert_expected_json_report(cov, expected_result)

0 commit comments

Comments
 (0)