diff options
-rw-r--r-- | CHANGES.rst | 6 | ||||
-rw-r--r-- | coverage/report.py | 38 | ||||
-rw-r--r-- | coverage/version.py | 2 |
3 files changed, 27 insertions, 19 deletions
diff --git a/CHANGES.rst b/CHANGES.rst index afd5f16a..86f5f725 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -21,6 +21,12 @@ want to know what's different in 5.0 since 4.5.x, see :ref:`whatsnew5x`. .. Version 9.8.1 --- 2027-07-27 .. ---------------------------- +Unreleased +---------- + +Nothing yet. + + .. _changes_55: Version 5.5 --- 2021-02-28 diff --git a/coverage/report.py b/coverage/report.py index 64678ff9..4ed0c7ef 100644 --- a/coverage/report.py +++ b/coverage/report.py @@ -10,27 +10,29 @@ from coverage.misc import CoverageException, NoSource, NotPython, ensure_dir_for def render_report(output_path, reporter, morfs): - """Run the provided reporter ensuring any required setup and cleanup is done + """Run a report generator, managing the output file. + + This function ensures the output file is ready to be written to. Then writes + the report to it. Then closes the file and cleans up. - At a high level this method ensures the output file is ready to be written to. Then writes the - report to it. Then closes the file and deletes any garbage created if necessary. """ file_to_close = None delete_file = False - if output_path: - if output_path == '-': - outfile = sys.stdout - else: - # Ensure that the output directory is created; done here - # because this report pre-opens the output file. - # HTMLReport does this using the Report plumbing because - # its task is more complex, being multiple files. - ensure_dir_for_file(output_path) - open_kwargs = {} - if env.PY3: - open_kwargs['encoding'] = 'utf8' - outfile = open(output_path, "w", **open_kwargs) - file_to_close = outfile + + if output_path == "-": + outfile = sys.stdout + else: + # Ensure that the output directory is created; done here + # because this report pre-opens the output file. + # HTMLReport does this using the Report plumbing because + # its task is more complex, being multiple files. + ensure_dir_for_file(output_path) + open_kwargs = {} + if env.PY3: + open_kwargs["encoding"] = "utf8" + outfile = open(output_path, "w", **open_kwargs) + file_to_close = outfile + try: return reporter.report(morfs, outfile=outfile) except CoverageException: @@ -40,7 +42,7 @@ def render_report(output_path, reporter, morfs): if file_to_close: file_to_close.close() if delete_file: - file_be_gone(output_path) + file_be_gone(output_path) # pragma: part covered (doesn't return) def get_analysis_to_report(coverage, morfs): diff --git a/coverage/version.py b/coverage/version.py index d141a11d..931cb98a 100644 --- a/coverage/version.py +++ b/coverage/version.py @@ -5,7 +5,7 @@ # This file is exec'ed in setup.py, don't import anything! # Same semantics as sys.version_info. -version_info = (5, 5, 0, "final", 0) +version_info = (5, 5, 1, "alpha", 0) def _make_version(major, minor, micro, releaselevel, serial): |