summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2021-05-23 13:06:10 -0400
committerNed Batchelder <ned@nedbatchelder.com>2021-05-23 13:06:10 -0400
commit24d12143463c9be51feefd65837821c037ec4005 (patch)
tree08dde611ed0a9f4febd278b719f6bbfe802d9a9c
parent01cbb8751f98e5a7de79699444cbc03647691616 (diff)
downloadpython-coveragepy-git-24d12143463c9be51feefd65837821c037ec4005.tar.gz
COVERAGE_DEBUG_FILE accepts "stdout" and "stderr"
-rw-r--r--CHANGES.rst3
-rw-r--r--coverage/debug.py4
-rw-r--r--doc/cmd.rst2
3 files changed, 8 insertions, 1 deletions
diff --git a/CHANGES.rst b/CHANGES.rst
index 3c65e5d8..1dd5c175 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -33,6 +33,9 @@ Unreleased
imported a file that will be measured" warnings about Django itself. These
have been fixed, closing `issue 1150`_.
+- The ``COVERAGE_DEBUG_FILE`` environment variable now accepts ``stdout`` and
+ ``stderr`` to write to those destinations.
+
.. _Django coverage plugin: https://pypi.org/project/django-coverage-plugin/
.. _issue 1150: https://github.com/nedbat/coveragepy/issues/1150
diff --git a/coverage/debug.py b/coverage/debug.py
index f86e0244..da4093ff 100644
--- a/coverage/debug.py
+++ b/coverage/debug.py
@@ -307,7 +307,9 @@ class DebugOutputFile: # pragma: debugging
if the_one is None or is_interim:
if fileobj is None:
debug_file_name = os.environ.get("COVERAGE_DEBUG_FILE", FORCED_DEBUG_FILE)
- if debug_file_name:
+ if debug_file_name in ("stdout", "stderr"):
+ fileobj = getattr(sys, debug_file_name)
+ elif debug_file_name:
fileobj = open(debug_file_name, "a")
else:
fileobj = sys.stderr
diff --git a/doc/cmd.rst b/doc/cmd.rst
index 111d1274..b4bf41ab 100644
--- a/doc/cmd.rst
+++ b/doc/cmd.rst
@@ -594,3 +594,5 @@ a comma-separated list of these options.
The debug output goes to stderr, unless the ``COVERAGE_DEBUG_FILE`` environment
variable names a different file, which will be appended to.
+``COVERAGE_DEBUG_FILE`` accepts the special names ``stdout`` and ``stderr`` to
+write to those destinations.