diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2019-12-21 11:41:57 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2019-12-21 11:41:57 -0500 |
commit | 31f7280b5f9a8fcd4b36f23f5b058deee602c4db (patch) | |
tree | 13f5bc83f2746399ebf2c1ef5640cb0df8d775e8 | |
parent | ade1f2c534d1b85c8b465ce302ab345b316ec3ef (diff) | |
download | python-coveragepy-git-31f7280b5f9a8fcd4b36f23f5b058deee602c4db.tar.gz |
Cleanup and changelog for #899 #900
-rw-r--r-- | CHANGES.rst | 6 | ||||
-rw-r--r-- | CONTRIBUTORS.txt | 1 | ||||
-rw-r--r-- | tests/test_json.py | 96 |
3 files changed, 57 insertions, 46 deletions
diff --git a/CHANGES.rst b/CHANGES.rst index 84672e28..37f36080 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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, @@ -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: diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 630e6c46..ced13685 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -42,6 +42,7 @@ Danny Allen David Christian David MacIver David Stanek +David Szotten Detlev Offenbach Devin Jeanpierre Dirk Thomas diff --git a/tests/test_json.py b/tests/test_json.py index 64de9292..2d2ae9f4 100644 --- a/tests/test_json.py +++ b/tests/test_json.py @@ -102,52 +102,56 @@ class JsonReportTest(UsingModulesMixin, CoverageTest): } 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) |