summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2020-04-11 16:21:41 -0400
committerNed Batchelder <ned@nedbatchelder.com>2020-04-11 16:21:41 -0400
commitb79005b3b7225497f55dfce872d72f9323ddf08c (patch)
tree974592d49d7c105959cc4ec118788ff580c7e0a0
parentb1194fbc5ca33e41b1b8ab467e0c758d3080750b (diff)
downloadpython-coveragepy-git-b79005b3b7225497f55dfce872d72f9323ddf08c.tar.gz
New JSON info should be reported on individual files also.
-rw-r--r--CHANGES.rst3
-rw-r--r--coverage/jsonreport.py2
-rw-r--r--tests/test_json.py6
3 files changed, 9 insertions, 2 deletions
diff --git a/CHANGES.rst b/CHANGES.rst
index b88341a0..cec94246 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -24,6 +24,9 @@ want to know what's different in 5.0 since 4.5.x, see :ref:`whatsnew5x`.
Unreleased
----------
+- The JSON report now includes counts of covered and missing branches. Thanks,
+ Salvatore Zagaria.
+
- On Python 3.8, try-finally-return reported wrong branch coverage with
decorated async functions (`issue 946`_). This is now fixed. Thanks, Kjell
Braden.
diff --git a/coverage/jsonreport.py b/coverage/jsonreport.py
index 1f544b0d..4287bc79 100644
--- a/coverage/jsonreport.py
+++ b/coverage/jsonreport.py
@@ -97,5 +97,7 @@ class JsonReporter(object):
reported_file['summary'].update({
'num_branches': nums.n_branches,
'num_partial_branches': nums.n_partial_branches,
+ 'covered_branches': nums.n_executed_branches,
+ 'missing_branches': nums.n_missing_branches,
})
return reported_file
diff --git a/tests/test_json.py b/tests/test_json.py
index 92dee6d9..f7ce7934 100644
--- a/tests/test_json.py
+++ b/tests/test_json.py
@@ -54,7 +54,9 @@ class JsonReportTest(UsingModulesMixin, CoverageTest):
'num_branches': 2,
'excluded_lines': 0,
'num_partial_branches': 1,
- 'percent_covered': 60.0
+ 'covered_branches': 1,
+ 'missing_branches': 1,
+ 'percent_covered': 60.0,
}
}
},
@@ -67,7 +69,7 @@ class JsonReportTest(UsingModulesMixin, CoverageTest):
'num_partial_branches': 1,
'percent_covered': 60.0,
'covered_branches': 1,
- 'missing_branches': 1
+ 'missing_branches': 1,
}
}
self._assert_expected_json_report(cov, expected_result)