summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2016-05-08 14:23:17 -0400
committerNed Batchelder <ned@nedbatchelder.com>2016-05-08 14:23:17 -0400
commit59e6ad6ccf9cb36eedd0417add05115785b00aad (patch)
tree3ad0e71e1ebcb26f4575f12b36eacd2aa7fb773a
parent6cb166021535eee3e57124ac6667d8ce2a73118f (diff)
downloadpython-coveragepy-git-59e6ad6ccf9cb36eedd0417add05115785b00aad.tar.gz
Return the Coverage instance from process_startup
-rw-r--r--CHANGES.rst4
-rw-r--r--coverage/control.py9
2 files changed, 11 insertions, 2 deletions
diff --git a/CHANGES.rst b/CHANGES.rst
index a6f0efa4..ff04775b 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -46,6 +46,9 @@ Unreleased
functions, but now at least we raise a more specific error message, rather
than getting confused. (`issue 456`_)
+- The `coverage.process_startup` function now returns the `Coverage` instance
+ it creates, as suggested in `issue 481`_.
+
- Make a small tweak to how we compare threads, to avoid buggy custom
comparison code in thread classes. (`issue 245`_)
@@ -58,6 +61,7 @@ Unreleased
.. _issue 472: https://bitbucket.org/ned/coveragepy/issues/472/html-report-indents-incorrectly-for-one
.. _issue 475: https://bitbucket.org/ned/coveragepy/issues/475/generator-expression-is-marked-as-not
.. _issue 479: https://bitbucket.org/ned/coveragepy/issues/479/clarify-the-need-for-the-c-extension
+.. _issue 481: https://bitbucket.org/ned/coveragepy/issues/481/asyncioprocesspoolexecutor-tracing-not
Version 4.1b2 --- 2016-01-23
diff --git a/coverage/control.py b/coverage/control.py
index e15b5a40..3e180745 100644
--- a/coverage/control.py
+++ b/coverage/control.py
@@ -1166,11 +1166,14 @@ def process_startup():
import coverage; coverage.process_startup()
+ Returns the :class:`Coverage` instance that was started, or None if it was
+ not started by this call.
+
"""
cps = os.environ.get("COVERAGE_PROCESS_START")
if not cps:
# No request for coverage, nothing to do.
- return
+ return None
# This function can be called more than once in a process. This happens
# because some virtualenv configurations make the same directory visible
@@ -1185,10 +1188,12 @@ def process_startup():
if hasattr(process_startup, "done"):
# We've annotated this function before, so we must have already
# started coverage.py in this process. Nothing to do.
- return
+ return None
process_startup.done = True
cov = Coverage(config_file=cps, auto_data=True)
cov.start()
cov._warn_no_data = False
cov._warn_unimported_source = False
+
+ return cov