diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2018-09-09 10:58:38 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2018-09-18 08:09:49 -0400 |
commit | 5aa95d1edec75c4f30458773894c7f47c1af0edc (patch) | |
tree | 26601985dd6bfce3822ae4d5f579211d1314497b | |
parent | 181f5a78fdbdb7d6f90a478482512297f3a0f845 (diff) | |
download | python-coveragepy-git-5aa95d1edec75c4f30458773894c7f47c1af0edc.tar.gz |
Plumb through context= setting
-rw-r--r-- | coverage/cmdline.py | 7 | ||||
-rw-r--r-- | coverage/config.py | 2 | ||||
-rw-r--r-- | coverage/control.py | 6 | ||||
-rw-r--r-- | tests/test_cmdline.py | 2 |
4 files changed, 14 insertions, 3 deletions
diff --git a/coverage/cmdline.py b/coverage/cmdline.py index 23d2aec3..99b155b2 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -43,6 +43,10 @@ class Opts(object): "Valid values are: %s." ) % ", ".join(CONCURRENCY_CHOICES), ) + context = optparse.make_option( + '', '--context', action='store', metavar="LABEL", + help="The context label to record for this coverage run", + ) debug = optparse.make_option( '', '--debug', action='store', metavar="OPTS", help="Debug options, separated by commas. [env: COVERAGE_DEBUG]", @@ -160,6 +164,7 @@ class CoverageOptionParser(optparse.OptionParser, object): append=None, branch=None, concurrency=None, + context=None, debug=None, directory=None, fail_under=None, @@ -358,6 +363,7 @@ CMDS = { Opts.append, Opts.branch, Opts.concurrency, + Opts.context, Opts.include, Opts.module, Opts.omit, @@ -482,6 +488,7 @@ class CoverageScript(object): debug=debug, concurrency=options.concurrency, check_preimported=True, + context=options.context, ) if options.action == "debug": diff --git a/coverage/config.py b/coverage/config.py index 69c929b4..9a11323d 100644 --- a/coverage/config.py +++ b/coverage/config.py @@ -175,6 +175,7 @@ class CoverageConfig(object): # Defaults for [run] self.branch = False self.concurrency = None + self.context = None self.cover_pylib = False self.data_file = ".coverage" self.debug = [] @@ -318,6 +319,7 @@ class CoverageConfig(object): # [run] ('branch', 'run:branch', 'boolean'), ('concurrency', 'run:concurrency', 'list'), + ('context', 'run:context'), ('cover_pylib', 'run:cover_pylib', 'boolean'), ('data_file', 'run:data_file'), ('debug', 'run:debug', 'list'), diff --git a/coverage/control.py b/coverage/control.py index 5d42af77..cdbd721f 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -57,7 +57,7 @@ class Coverage(object): self, data_file=None, data_suffix=None, cover_pylib=None, auto_data=False, timid=None, branch=None, config_file=True, source=None, omit=None, include=None, debug=None, - concurrency=None, check_preimported=False, + concurrency=None, check_preimported=False, context=None, ): """ `data_file` is the base name of the data file to use, defaulting to @@ -116,6 +116,8 @@ class Coverage(object): by coverage. Importing measured files before coverage is started can mean that code is missed. + `context` is a string to use as the context label for collected data. + .. versionadded:: 4.0 The `concurrency` parameter. @@ -133,7 +135,7 @@ class Coverage(object): branch=branch, parallel=bool_or_none(data_suffix), source=source, run_omit=omit, run_include=include, debug=debug, report_omit=omit, report_include=include, - concurrency=concurrency, + concurrency=concurrency, context=context, ) # This is injectable by tests. diff --git a/tests/test_cmdline.py b/tests/test_cmdline.py index a4d01880..92867a54 100644 --- a/tests/test_cmdline.py +++ b/tests/test_cmdline.py @@ -33,7 +33,7 @@ class BaseCmdLineTest(CoverageTest): defaults.Coverage( cover_pylib=None, data_suffix=None, timid=None, branch=None, config_file=True, source=None, include=None, omit=None, debug=None, - concurrency=None, check_preimported=True, + concurrency=None, check_preimported=True, context=None, ) defaults.annotate( directory=None, ignore_errors=None, include=None, omit=None, morfs=[], |