diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2015-07-26 15:03:11 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2015-07-26 15:03:11 -0400 |
commit | dffe029fd2118edb145916c9f706af6522bd6274 (patch) | |
tree | 86ce0803b0326005921cb4944102a36c30b148c1 | |
parent | 74a638cd9b04d64c9484444ea760499607253497 (diff) | |
download | python-coveragepy-git-dffe029fd2118edb145916c9f706af6522bd6274.tar.gz |
New config option: run:note lets you annotate the data file.
-rw-r--r-- | CHANGES.txt | 10 | ||||
-rw-r--r-- | coverage/cmdline.py | 2 | ||||
-rw-r--r-- | coverage/config.py | 2 | ||||
-rw-r--r-- | coverage/control.py | 3 | ||||
-rw-r--r-- | tests/test_config.py | 2 | ||||
-rw-r--r-- | tests/test_process.py | 18 |
6 files changed, 31 insertions, 6 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index de65cfa6..ffa4f32e 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -16,6 +16,10 @@ Latest almost-JSON instead of a pickle, closing `issue 236`_. The `CoverageData` class is now a public supported API to the data file. +- A new configuration option, ``[run] note``, lets you set a note that will be + stored in the `runs` section of the data file. You can use this to annotate + the data file with any information you like. + - The XML report now includes a ``missing-branches`` attribute. Thanks, Steve Peak. This is not a part of the Cobertura DTD, so the XML report no longer references the DTD. @@ -68,7 +72,7 @@ Version 4.0a6 --- 21 June 2015 persisted in pursuing this despite Ned's pessimism. Fixes `issue 308`_ and `issue 324`_. -- The COVERAGE_DEBUG environment variable can be used to set the `[run]debug` +- The COVERAGE_DEBUG environment variable can be used to set the ``[run] debug`` configuration option to control what internal operations are logged. - HTML reports were truncated at formfeed characters. This is now fixed @@ -438,7 +442,7 @@ Version 3.6b1 --- 28 November 2012 - Configuration files now support substitution of environment variables, using syntax like ``${WORD}``. Closes `issue 97`_. -- Embarrassingly, the `[xml] output=` setting in the .coveragerc file simply +- Embarrassingly, the ``[xml] output=`` setting in the .coveragerc file simply didn't work. Now it does. - The XML report now consistently uses filenames for the filename attribute, @@ -579,7 +583,7 @@ Version 3.5.2b1 --- 29 April 2012 the page are color-coded to the source lines they affect. - Custom CSS can be applied to the HTML report by specifying a CSS file as - the extra_css configuration value in the [html] section. + the ``extra_css`` configuration value in the ``[html]`` section. - Source files with custom encodings declared in a comment at the top are now properly handled during reporting on Python 2. Python 3 always handled them diff --git a/coverage/cmdline.py b/coverage/cmdline.py index ff980733..b4deb588 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -301,7 +301,7 @@ CMDS = { Opts.include, Opts.omit, Opts.show_missing, - Opts.skip_covered + Opts.skip_covered, ] + GLOBAL_ARGS, usage = "[options] [modules]", description = "Report coverage statistics on modules." diff --git a/coverage/config.py b/coverage/config.py index d7669752..c64be6c3 100644 --- a/coverage/config.py +++ b/coverage/config.py @@ -161,6 +161,7 @@ class CoverageConfig(object): self.cover_pylib = False self.data_file = ".coverage" self.debug = [] + self.note = None self.parallel = False self.plugins = [] self.source = None @@ -261,6 +262,7 @@ class CoverageConfig(object): ('data_file', 'run:data_file'), ('debug', 'run:debug', 'list'), ('include', 'run:include', 'list'), + ('note', 'run:note'), ('omit', 'run:omit', 'list'), ('parallel', 'run:parallel', 'boolean'), ('plugins', 'run:plugins', 'list'), diff --git a/coverage/control.py b/coverage/control.py index 2ad0db0f..8a671fe0 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -788,6 +788,9 @@ class Coverage(object): ]) ) + if self.config.note: + self.data.add_run_info(note=self.config.note) + self._measured = False return self.data diff --git a/tests/test_config.py b/tests/test_config.py index 6234ac5f..8b2b28f0 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# coding: utf-8 # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 # For details: https://bitbucket.org/ned/coveragepy/src/default/NOTICE.txt diff --git a/tests/test_process.py b/tests/test_process.py index 8255f98c..e4fa7417 100644 --- a/tests/test_process.py +++ b/tests/test_process.py @@ -1,3 +1,4 @@ +# coding: utf8 # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 # For details: https://bitbucket.org/ned/coveragepy/src/default/NOTICE.txt @@ -10,7 +11,7 @@ import sys import textwrap import coverage -from coverage import env +from coverage import env, CoverageData from tests.coveragetest import CoverageTest @@ -534,6 +535,21 @@ class ProcessTest(CoverageTest): self.assertIn("Trace function changed", out) + def test_note(self): + self.make_file(".coveragerc", """\ + [run] + data_file = mydata.dat + note = These are musical notes: ♫𝅗𝅥♩ + """) + self.make_file("simple.py", """print('hello')""") + self.run_command("coverage run simple.py") + + data = CoverageData() + data.read_file("mydata.dat") + infos = data.run_infos() + self.assertEqual(len(infos), 1) + self.assertEqual(infos[0]['note'], u"These are musical notes: ♫𝅗𝅥♩") + def test_fullcoverage(self): # pragma: not covered if env.PY2: # This doesn't work on Python 2. self.skip("fullcoverage doesn't work on Python 2.") |