diff options
-rw-r--r-- | CHANGES.rst | 3 | ||||
-rw-r--r-- | coverage/debug.py | 4 | ||||
-rw-r--r-- | doc/cmd.rst | 2 |
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. |