Commit 9a30eb1c authored by Dom Sekotill's avatar Dom Sekotill
Browse files

prevent coverage report from closing stdout

If reporting coverage to stdout, don't close it once the report is
complete.
parent 7420ace1
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@
A module to produce coverage reports for testing.
"""

from six import string_types
from six import string_types, PY3
from itertools import product
from functools import wraps
from fnmatch import fnmatch
@@ -35,6 +35,7 @@ import itertools
import logging
import pkgutil
import sys
import io


def _import_module(module, exclude):
@@ -100,7 +101,8 @@ def coverage_report(modules, include=None, exclude=None, file=None):
		cover.stop()
		cover.save()

		with (file or sys.stdout) as file:
		mode = 'w' if PY3 else 'wb'
		with file or io.open(sys.stdout.fileno(), mode, closefd=False) as file:
			if file.isatty():
				file.write("\nCoverage Report:\n================\n")
			cover.report(list(modules), include=include, omit=exclude, file=file)