Skip to content

Commit

Permalink
Cleanup and changelog for #899 #900
Browse files Browse the repository at this point in the history
  • Loading branch information
nedbat committed Dec 21, 2019
1 parent ade1f2c commit 31f7280
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 46 deletions.
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ want to know what's different in 5.0 since 4.5.x, see :ref:`whatsnew5x`.
Unreleased
----------

- Measurement contexts and relative file names didn't work together, as
reported in `issue_899`_ and `issue_900`_. This is now fixed, thanks to
David Szotten.

- When using ``coverage run --concurrency=multiprocessing``, all data files
should be named with parallel-ready suffixes. 5.0 mistakenly named the main
process' file with no suffix when using ``--append``. This is now fixed,
Expand All @@ -34,6 +38,8 @@ Unreleased

.. _issue 880: https://github.com/nedbat/coveragepy/issues/880
.. _issue 895: https://github.com/nedbat/coveragepy/issues/895
.. _issue 899: https://github.com/nedbat/coveragepy/issues/899
.. _issue 900: https://github.com/nedbat/coveragepy/issues/900


.. _changes_50:
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Danny Allen
David Christian
David MacIver
David Stanek
David Szotten
Detlev Offenbach
Devin Jeanpierre
Dirk Thomas
Expand Down
96 changes: 50 additions & 46 deletions tests/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,52 +102,56 @@ def test_simple_line_coverage(self):
}
self._assert_expected_json_report(cov, expected_result)

def test_context(self):
for relative_files in [False, True]:
config_file = os.path.join(self.temp_dir, "config")
with open(config_file, 'w') as handle:
handle.write(
"[run]\nrelative_files = {}".format(relative_files)
)
cov = coverage.Coverage(
context="cool_test",
config_file=config_file
)
cov.config.json_show_contexts = True
expected_result = {
'meta': {
"version": coverage.__version__,
"branch_coverage": False,
"show_contexts": True,
},
'files': {
'a.py': {
'executed_lines': [1, 2],
'missing_lines': [3],
'excluded_lines': [],
"contexts": {
"1": [
"cool_test"
],
"2": [
"cool_test"
]
},
'summary': {
'excluded_lines': 0,
'missing_lines': 1,
'covered_lines': 2,
'num_statements': 3,
'percent_covered': 66.66666666666667
}
def run_context_test(self, relative_files):
"""A helper for two tests below."""
self.make_file("config", """\
[run]
relative_files = {}
[json]
show_contexts = True
""".format(relative_files))
cov = coverage.Coverage(context="cool_test", config_file="config")
expected_result = {
'meta': {
"version": coverage.__version__,
"branch_coverage": False,
"show_contexts": True,
},
'files': {
'a.py': {
'executed_lines': [1, 2],
'missing_lines': [3],
'excluded_lines': [],
"contexts": {
"1": [
"cool_test"
],
"2": [
"cool_test"
]
},
'summary': {
'excluded_lines': 0,
'missing_lines': 1,
'covered_lines': 2,
'num_statements': 3,
'percent_covered': 66.66666666666667
}
},
'totals': {
'excluded_lines': 0,
'missing_lines': 1,
'covered_lines': 2,
'num_statements': 3,
'percent_covered': 66.66666666666667
}
},
'totals': {
'excluded_lines': 0,
'missing_lines': 1,
'covered_lines': 2,
'num_statements': 3,
'percent_covered': 66.66666666666667
}
self._assert_expected_json_report(cov, expected_result)
}
self._assert_expected_json_report(cov, expected_result)

def test_context_non_relative(self):
self.run_context_test(relative_files=False)

def test_context_relative(self):
self.run_context_test(relative_files=True)

0 comments on commit 31f7280

Please sign in to comment.