From a3220ee416cb5a1989c0d3b1863a794965c04a23 Mon Sep 17 00:00:00 2001 From: "J. M. F. Tsang" Date: Fri, 22 Apr 2022 00:32:11 +0100 Subject: [PATCH 1/7] Keyboard shortcuts for previous and next page On each page the shortcuts '[' and ']' will take you to the previous and next files respectively. On the index page they take you to the final and first files respectively. Test cases: $ pytest --cov-report html --cov=. tests.py in a directory with just tests.py, then with one, two or three .py files. Tested on Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:99.0) Gecko/20100101 Firefox/99.0 --- coverage/html.py | 60 ++++++++++++++++++++++++++--- coverage/htmlfiles/coverage_html.js | 27 ++++++++++--- coverage/htmlfiles/index.html | 13 +++++++ coverage/htmlfiles/pyfile.html | 14 ++++++- 4 files changed, 101 insertions(+), 13 deletions(-) diff --git a/coverage/html.py b/coverage/html.py index 342d2ad1c..7f60b8abc 100644 --- a/coverage/html.py +++ b/coverage/html.py @@ -165,6 +165,8 @@ def __init__(self, cov): self.datagen = HtmlDataGeneration(self.coverage) self.totals = Numbers(precision=self.config.precision) self.directory_was_empty = False + self.first_fr = None + self.final_fr = None self.template_globals = { # Functions available in the templates. @@ -204,9 +206,27 @@ def report(self, morfs): self.incr.read() self.incr.check_global_data(self.config, self.pyfile_html_source) - # Process all the files. - for fr, analysis in get_analysis_to_report(self.coverage, morfs): - self.html_file(fr, analysis) + # Process all the files. For each page we need to supply a link + # to the next page. Therefore in each iteration of the loop we + # work on the fr and analysis from the previous iteration. We + # also need a link to the preceding page (i.e. 2 before the + # current iteration). + analysis_to_report = get_analysis_to_report(self.coverage, morfs) + pluprev_fr, prev_fr = None, None + prev_analysis = None + + for fr, analysis in analysis_to_report: + if prev_fr is not None: + self.html_file(prev_fr, prev_analysis, pluprev_fr, fr) + else: + # This is the first file processed + self.first_fr = fr + pluprev_fr, prev_fr, prev_analysis = prev_fr, fr, analysis + + # One more iteration for the final file. + self.html_file(prev_fr, prev_analysis, pluprev_fr, None) + # This is the last file processed + self.final_fr = prev_fr if not self.all_files_nums: raise NoDataError("No data to report.") @@ -236,10 +256,22 @@ def make_local_static_report_files(self): if self.extra_css: shutil.copyfile(self.config.extra_css, os.path.join(self.directory, self.extra_css)) - def html_file(self, fr, analysis): - """Generate an HTML file for one source file.""" + def html_file(self, fr, analysis, prev_fr=None, next_fr=None): + """Generate an HTML file for one source file, with links to the + previous and the next file, or to the index.""" rootname = flat_rootname(fr.relative_filename()) html_filename = rootname + ".html" + if prev_fr is not None: + prev_html = flat_rootname(prev_fr.relative_filename()) + ".html" + else: + prev_html = "index.html" + + if next_fr is not None: + next_html = flat_rootname(next_fr.relative_filename()) + ".html" + else: + next_html = "index.html" + + print(prev_html, html_filename, next_html) ensure_dir(self.directory) if not os.listdir(self.directory): self.directory_was_empty = True @@ -316,7 +348,11 @@ def html_file(self, fr, analysis): css_classes.append(self.template_globals['category'][ldata.category]) ldata.css_class = ' '.join(css_classes) or "pln" - html = self.source_tmpl.render(file_data.__dict__) + html = self.source_tmpl.render({ + **file_data.__dict__, + 'prev_html': prev_html, + 'next_html': next_html, + }) write_html(html_path, html) # Save this file's information for the index file. @@ -340,11 +376,23 @@ def index_file(self): n = self.skipped_empty_count skipped_empty_msg = f"{n} empty file{plural(n)} skipped." + if self.first_fr is not None: + first_html = flat_rootname(self.first_fr.relative_filename()) + ".html" + else: + first_html = "index.html" + + if self.final_fr is not None: + final_html = flat_rootname(self.final_fr.relative_filename()) + ".html" + else: + final_html = "index.html" + html = index_tmpl.render({ 'files': self.file_summaries, 'totals': self.totals, 'skipped_covered_msg': skipped_covered_msg, 'skipped_empty_msg': skipped_empty_msg, + 'first_html': first_html, + 'final_html': final_html, }) index_file = os.path.join(self.directory, "index.html") diff --git a/coverage/htmlfiles/coverage_html.js b/coverage/htmlfiles/coverage_html.js index 00e18488d..1faf24f72 100644 --- a/coverage/htmlfiles/coverage_html.js +++ b/coverage/htmlfiles/coverage_html.js @@ -25,6 +25,13 @@ function checkVisible(element) { return !(rect.bottom < viewTop || rect.top >= viewBottom); } +function on_click(sel, fn) { + const elt = document.querySelector(sel); + if (elt) { + elt.addEventListener("click", fn); + } +} + // Helpers for table sorting function getCellValue(row, column = 0) { const cell = row.cells[column] @@ -193,6 +200,9 @@ coverage.index_ready = function () { direction: th.getAttribute("aria-sort"), })); }); + + on_click(".button_prev_file", coverage.to_prev_file); + on_click(".button_next_file", coverage.to_next_file); }; // -- pyfile stuff -- @@ -209,12 +219,6 @@ coverage.pyfile_ready = function () { coverage.set_sel(0); } - const on_click = function(sel, fn) { - const elt = document.querySelector(sel); - if (elt) { - elt.addEventListener("click", fn); - } - } on_click(".button_toggle_run", coverage.toggle_lines); on_click(".button_toggle_mis", coverage.toggle_lines); on_click(".button_toggle_exc", coverage.toggle_lines); @@ -225,6 +229,9 @@ coverage.pyfile_ready = function () { on_click(".button_top_of_page", coverage.to_top); on_click(".button_first_chunk", coverage.to_first_chunk); + on_click(".button_prev_file", coverage.to_prev_file); + on_click(".button_next_file", coverage.to_next_file); + coverage.filters = undefined; try { coverage.filters = localStorage.getItem(coverage.LINE_FILTERS_STORAGE); @@ -299,6 +306,14 @@ coverage.to_first_chunk = function () { coverage.to_next_chunk(); }; +coverage.to_prev_file = function () { + window.location = document.getElementById("prevFileLink").href; +} + +coverage.to_next_file = function () { + window.location = document.getElementById("nextFileLink").href; +} + // Return a string indicating what kind of chunk this line belongs to, // or null if not a chunk. coverage.chunk_indicator = function (line_elt) { diff --git a/coverage/htmlfiles/index.html b/coverage/htmlfiles/index.html index e1d3e9b59..b740c0720 100644 --- a/coverage/htmlfiles/index.html +++ b/coverage/htmlfiles/index.html @@ -40,6 +40,11 @@

{{ title|escape }}: {% endif %} c   change column sorting

+

+ [ + ] +   prev/next file +

@@ -115,6 +120,14 @@

{{ title|escape }}: created at {{ time_stamp }}

+
+

+ first file + final file +

+ + +
diff --git a/coverage/htmlfiles/pyfile.html b/coverage/htmlfiles/pyfile.html index fdad9d4ec..17c94fd16 100644 --- a/coverage/htmlfiles/pyfile.html +++ b/coverage/htmlfiles/pyfile.html @@ -52,6 +52,11 @@

1   (one) first highlighted chunk

+

+ [ + ] +   prev/next file +

@@ -71,6 +76,8 @@

+ + @@ -110,7 +117,12 @@

- « index     coverage.py v{{__version__}}, + « prev file     + ^ index     + » next file +

+

+ coverage.py v{{__version__}}, created at {{ time_stamp }}

From 697b1e15154e00f34dc1e687bd5d1296303c8248 Mon Sep 17 00:00:00 2001 From: "J. M. F. Tsang" Date: Fri, 22 Apr 2022 09:45:31 +0100 Subject: [PATCH 2/7] Add keyboard shortcut for going back to the index Pressing 'u' while on a file will now take you back to index.html, like on Gerrit. --- coverage/htmlfiles/coverage_html.js | 5 +++++ coverage/htmlfiles/pyfile.html | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/coverage/htmlfiles/coverage_html.js b/coverage/htmlfiles/coverage_html.js index 1faf24f72..6f345273d 100644 --- a/coverage/htmlfiles/coverage_html.js +++ b/coverage/htmlfiles/coverage_html.js @@ -231,6 +231,7 @@ coverage.pyfile_ready = function () { on_click(".button_prev_file", coverage.to_prev_file); on_click(".button_next_file", coverage.to_next_file); + on_click(".button_to_index", coverage.to_index); coverage.filters = undefined; try { @@ -314,6 +315,10 @@ coverage.to_next_file = function () { window.location = document.getElementById("nextFileLink").href; } +coverage.to_index = function () { + location.href = document.getElementById("indexLink").href; +} + // Return a string indicating what kind of chunk this line belongs to, // or null if not a chunk. coverage.chunk_indicator = function (line_elt) { diff --git a/coverage/htmlfiles/pyfile.html b/coverage/htmlfiles/pyfile.html index 17c94fd16..73f1dc819 100644 --- a/coverage/htmlfiles/pyfile.html +++ b/coverage/htmlfiles/pyfile.html @@ -57,6 +57,9 @@

]   prev/next file

+

+ u   back to the index +

@@ -78,6 +81,7 @@

+ @@ -118,7 +122,7 @@

« prev file     - ^ index     + ^ index     » next file

From 621da42014c9ee5b370344acb00efc672d090a04 Mon Sep 17 00:00:00 2001 From: "J. M. F. Tsang" Date: Fri, 22 Apr 2022 19:34:54 +0100 Subject: [PATCH 3/7] Add keyboard shortcut for showing/hiding the help panel --- coverage/htmlfiles/coverage_html.js | 9 +++++++++ coverage/htmlfiles/index.html | 4 ++++ coverage/htmlfiles/pyfile.html | 6 +++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/coverage/htmlfiles/coverage_html.js b/coverage/htmlfiles/coverage_html.js index 6f345273d..084a4970c 100644 --- a/coverage/htmlfiles/coverage_html.js +++ b/coverage/htmlfiles/coverage_html.js @@ -203,6 +203,8 @@ coverage.index_ready = function () { on_click(".button_prev_file", coverage.to_prev_file); on_click(".button_next_file", coverage.to_next_file); + + on_click(".button_show_hide_help", coverage.show_hide_help); }; // -- pyfile stuff -- @@ -233,6 +235,8 @@ coverage.pyfile_ready = function () { on_click(".button_next_file", coverage.to_next_file); on_click(".button_to_index", coverage.to_index); + on_click(".button_show_hide_help", coverage.show_hide_help); + coverage.filters = undefined; try { coverage.filters = localStorage.getItem(coverage.LINE_FILTERS_STORAGE); @@ -319,6 +323,11 @@ coverage.to_index = function () { location.href = document.getElementById("indexLink").href; } +coverage.show_hide_help = function () { + const helpCheck = document.getElementById("help_panel_state") + helpCheck.checked = !helpCheck.checked; +} + // Return a string indicating what kind of chunk this line belongs to, // or null if not a chunk. coverage.chunk_indicator = function (line_elt) { diff --git a/coverage/htmlfiles/index.html b/coverage/htmlfiles/index.html index b740c0720..9f8e88e69 100644 --- a/coverage/htmlfiles/index.html +++ b/coverage/htmlfiles/index.html @@ -45,6 +45,9 @@

{{ title|escape }}: ]   prev/next file

+

+ ?   show/hide this help +

@@ -127,6 +130,7 @@

{{ title|escape }}:

+

diff --git a/coverage/htmlfiles/pyfile.html b/coverage/htmlfiles/pyfile.html index 73f1dc819..7bd56d42a 100644 --- a/coverage/htmlfiles/pyfile.html +++ b/coverage/htmlfiles/pyfile.html @@ -57,9 +57,12 @@

]   prev/next file

-

+

u   back to the index

+

+ ?   show/hide this help +

@@ -82,6 +85,7 @@

+ From bb1e2717e31825647356c89a5979b13bd4af5fe2 Mon Sep 17 00:00:00 2001 From: "J. M. F. Tsang" Date: Mon, 25 Apr 2022 21:26:06 +0100 Subject: [PATCH 4/7] Update gold files --- tests/gold/html/a/a_py.html | 24 ++++++++++++++-- tests/gold/html/a/index.html | 21 ++++++++++++-- tests/gold/html/b_branch/b_py.html | 24 ++++++++++++++-- tests/gold/html/b_branch/index.html | 21 ++++++++++++-- tests/gold/html/bom/bom_py.html | 24 ++++++++++++++-- tests/gold/html/bom/index.html | 21 ++++++++++++-- tests/gold/html/isolatin1/index.html | 21 ++++++++++++-- tests/gold/html/isolatin1/isolatin1_py.html | 24 ++++++++++++++-- tests/gold/html/omit_1/index.html | 21 ++++++++++++-- tests/gold/html/omit_1/m1_py.html | 24 ++++++++++++++-- tests/gold/html/omit_1/m2_py.html | 24 ++++++++++++++-- tests/gold/html/omit_1/m3_py.html | 24 ++++++++++++++-- tests/gold/html/omit_1/main_py.html | 24 ++++++++++++++-- tests/gold/html/omit_2/index.html | 21 ++++++++++++-- tests/gold/html/omit_2/m2_py.html | 24 ++++++++++++++-- tests/gold/html/omit_2/m3_py.html | 24 ++++++++++++++-- tests/gold/html/omit_2/main_py.html | 24 ++++++++++++++-- tests/gold/html/omit_3/index.html | 21 ++++++++++++-- tests/gold/html/omit_3/m3_py.html | 24 ++++++++++++++-- tests/gold/html/omit_3/main_py.html | 24 ++++++++++++++-- tests/gold/html/omit_4/index.html | 21 ++++++++++++-- tests/gold/html/omit_4/m1_py.html | 24 ++++++++++++++-- tests/gold/html/omit_4/m3_py.html | 24 ++++++++++++++-- tests/gold/html/omit_4/main_py.html | 24 ++++++++++++++-- tests/gold/html/omit_5/index.html | 21 ++++++++++++-- tests/gold/html/omit_5/m1_py.html | 24 ++++++++++++++-- tests/gold/html/omit_5/main_py.html | 24 ++++++++++++++-- tests/gold/html/other/blah_blah_other_py.html | 28 ++++++++++++++++--- tests/gold/html/other/here_py.html | 24 ++++++++++++++-- tests/gold/html/other/index.html | 23 +++++++++++++-- tests/gold/html/partial/index.html | 21 ++++++++++++-- tests/gold/html/partial/partial_py.html | 24 ++++++++++++++-- tests/gold/html/styled/a_py.html | 24 ++++++++++++++-- tests/gold/html/styled/index.html | 21 ++++++++++++-- tests/gold/html/unicode/index.html | 21 ++++++++++++-- tests/gold/html/unicode/unicode_py.html | 24 ++++++++++++++-- 36 files changed, 756 insertions(+), 75 deletions(-) diff --git a/tests/gold/html/a/a_py.html b/tests/gold/html/a/a_py.html index 14960385a..3e63a5a29 100644 --- a/tests/gold/html/a/a_py.html +++ b/tests/gold/html/a/a_py.html @@ -39,6 +39,17 @@

1   (one) first highlighted chunk

+

+ [ + ] +   prev/next file +

+

+ u   back to the index +

+

+ ?   show/hide this help +

@@ -53,6 +64,10 @@

+ + + + @@ -66,8 +81,13 @@

diff --git a/tests/gold/html/a/index.html b/tests/gold/html/a/index.html index cb7533d21..4b07e05c4 100644 --- a/tests/gold/html/a/index.html +++ b/tests/gold/html/a/index.html @@ -28,6 +28,14 @@

Coverage report: x c   change column sorting

+

+ [ + ] +   prev/next file +

+

+ ?   show/hide this help +

@@ -73,9 +81,18 @@

Coverage report: diff --git a/tests/gold/html/b_branch/b_py.html b/tests/gold/html/b_branch/b_py.html index 34508cb8a..d77f0e3bf 100644 --- a/tests/gold/html/b_branch/b_py.html +++ b/tests/gold/html/b_branch/b_py.html @@ -40,6 +40,17 @@

1   (one) first highlighted chunk

+

+ [ + ] +   prev/next file +

+

+ u   back to the index +

+

+ ?   show/hide this help +

@@ -55,6 +66,10 @@

+ + + + @@ -90,8 +105,13 @@

diff --git a/tests/gold/html/b_branch/index.html b/tests/gold/html/b_branch/index.html index 6b1a2b415..2dd2649d1 100644 --- a/tests/gold/html/b_branch/index.html +++ b/tests/gold/html/b_branch/index.html @@ -30,6 +30,14 @@

Coverage report: p c   change column sorting

+

+ [ + ] +   prev/next file +

+

+ ?   show/hide this help +

@@ -81,9 +89,18 @@

Coverage report: diff --git a/tests/gold/html/bom/bom_py.html b/tests/gold/html/bom/bom_py.html index 0b92d92f1..3c90d9303 100644 --- a/tests/gold/html/bom/bom_py.html +++ b/tests/gold/html/bom/bom_py.html @@ -39,6 +39,17 @@

1   (one) first highlighted chunk

+

+ [ + ] +   prev/next file +

+

+ u   back to the index +

+

+ ?   show/hide this help +

@@ -53,6 +64,10 @@

+ + + + @@ -72,8 +87,13 @@

diff --git a/tests/gold/html/bom/index.html b/tests/gold/html/bom/index.html index 3814fa422..7c796341f 100644 --- a/tests/gold/html/bom/index.html +++ b/tests/gold/html/bom/index.html @@ -28,6 +28,14 @@

Coverage report: x c   change column sorting

+

+ [ + ] +   prev/next file +

+

+ ?   show/hide this help +

@@ -73,9 +81,18 @@

Coverage report: diff --git a/tests/gold/html/isolatin1/index.html b/tests/gold/html/isolatin1/index.html index b2027c085..43ba843ad 100644 --- a/tests/gold/html/isolatin1/index.html +++ b/tests/gold/html/isolatin1/index.html @@ -28,6 +28,14 @@

Coverage report: x c   change column sorting

+

+ [ + ] +   prev/next file +

+

+ ?   show/hide this help +

@@ -73,9 +81,18 @@

Coverage report: diff --git a/tests/gold/html/isolatin1/isolatin1_py.html b/tests/gold/html/isolatin1/isolatin1_py.html index cdd4770af..ec570087b 100644 --- a/tests/gold/html/isolatin1/isolatin1_py.html +++ b/tests/gold/html/isolatin1/isolatin1_py.html @@ -39,6 +39,17 @@

1   (one) first highlighted chunk

+

+ [ + ] +   prev/next file +

+

+ u   back to the index +

+

+ ?   show/hide this help +

@@ -53,6 +64,10 @@

+ + + + @@ -66,8 +81,13 @@

diff --git a/tests/gold/html/omit_1/index.html b/tests/gold/html/omit_1/index.html index 5a1b04124..48d2d3c0b 100644 --- a/tests/gold/html/omit_1/index.html +++ b/tests/gold/html/omit_1/index.html @@ -28,6 +28,14 @@

Coverage report: x c   change column sorting

+

+ [ + ] +   prev/next file +

+

+ ?   show/hide this help +

@@ -94,9 +102,18 @@

Coverage report: diff --git a/tests/gold/html/omit_1/m1_py.html b/tests/gold/html/omit_1/m1_py.html index 761819180..bc961b168 100644 --- a/tests/gold/html/omit_1/m1_py.html +++ b/tests/gold/html/omit_1/m1_py.html @@ -39,6 +39,17 @@

1   (one) first highlighted chunk

+

+ [ + ] +   prev/next file +

+

+ u   back to the index +

+

+ ?   show/hide this help +

@@ -53,6 +64,10 @@

+ + + + @@ -63,8 +78,13 @@

diff --git a/tests/gold/html/omit_1/m2_py.html b/tests/gold/html/omit_1/m2_py.html index 3f5971848..4157a65f2 100644 --- a/tests/gold/html/omit_1/m2_py.html +++ b/tests/gold/html/omit_1/m2_py.html @@ -39,6 +39,17 @@

1   (one) first highlighted chunk

+

+ [ + ] +   prev/next file +

+

+ u   back to the index +

+

+ ?   show/hide this help +

@@ -53,6 +64,10 @@

+ + + + @@ -63,8 +78,13 @@

diff --git a/tests/gold/html/omit_1/m3_py.html b/tests/gold/html/omit_1/m3_py.html index 9cf26e2e0..c50fe5261 100644 --- a/tests/gold/html/omit_1/m3_py.html +++ b/tests/gold/html/omit_1/m3_py.html @@ -39,6 +39,17 @@

1   (one) first highlighted chunk

+

+ [ + ] +   prev/next file +

+

+ u   back to the index +

+

+ ?   show/hide this help +

@@ -53,6 +64,10 @@

+ + + + @@ -63,8 +78,13 @@

diff --git a/tests/gold/html/omit_1/main_py.html b/tests/gold/html/omit_1/main_py.html index c51dc5ced..3d44172d8 100644 --- a/tests/gold/html/omit_1/main_py.html +++ b/tests/gold/html/omit_1/main_py.html @@ -39,6 +39,17 @@

1   (one) first highlighted chunk

+

+ [ + ] +   prev/next file +

+

+ u   back to the index +

+

+ ?   show/hide this help +

@@ -53,6 +64,10 @@

+ + + + @@ -71,8 +86,13 @@

diff --git a/tests/gold/html/omit_2/index.html b/tests/gold/html/omit_2/index.html index 4edc4753d..6fddedef6 100644 --- a/tests/gold/html/omit_2/index.html +++ b/tests/gold/html/omit_2/index.html @@ -28,6 +28,14 @@

Coverage report: x c   change column sorting

+

+ [ + ] +   prev/next file +

+

+ ?   show/hide this help +

@@ -87,9 +95,18 @@

Coverage report: diff --git a/tests/gold/html/omit_2/m2_py.html b/tests/gold/html/omit_2/m2_py.html index 3f5971848..ef5ad89b7 100644 --- a/tests/gold/html/omit_2/m2_py.html +++ b/tests/gold/html/omit_2/m2_py.html @@ -39,6 +39,17 @@

1   (one) first highlighted chunk

+

+ [ + ] +   prev/next file +

+

+ u   back to the index +

+

+ ?   show/hide this help +

@@ -53,6 +64,10 @@

+ + + + @@ -63,8 +78,13 @@

diff --git a/tests/gold/html/omit_2/m3_py.html b/tests/gold/html/omit_2/m3_py.html index 9cf26e2e0..b0c45078b 100644 --- a/tests/gold/html/omit_2/m3_py.html +++ b/tests/gold/html/omit_2/m3_py.html @@ -39,6 +39,17 @@

1   (one) first highlighted chunk

+

+ [ + ] +   prev/next file +

+

+ u   back to the index +

+

+ ?   show/hide this help +

@@ -53,6 +64,10 @@

+ + + + @@ -63,8 +78,13 @@

diff --git a/tests/gold/html/omit_2/main_py.html b/tests/gold/html/omit_2/main_py.html index c51dc5ced..7a74fd4a9 100644 --- a/tests/gold/html/omit_2/main_py.html +++ b/tests/gold/html/omit_2/main_py.html @@ -39,6 +39,17 @@

1   (one) first highlighted chunk

+

+ [ + ] +   prev/next file +

+

+ u   back to the index +

+

+ ?   show/hide this help +

@@ -53,6 +64,10 @@

+ + + + @@ -71,8 +86,13 @@

diff --git a/tests/gold/html/omit_3/index.html b/tests/gold/html/omit_3/index.html index 5c720c737..7f23713c4 100644 --- a/tests/gold/html/omit_3/index.html +++ b/tests/gold/html/omit_3/index.html @@ -28,6 +28,14 @@

Coverage report: x c   change column sorting

+

+ [ + ] +   prev/next file +

+

+ ?   show/hide this help +

@@ -80,9 +88,18 @@

Coverage report: diff --git a/tests/gold/html/omit_3/m3_py.html b/tests/gold/html/omit_3/m3_py.html index 9cf26e2e0..1cc55fdf8 100644 --- a/tests/gold/html/omit_3/m3_py.html +++ b/tests/gold/html/omit_3/m3_py.html @@ -39,6 +39,17 @@

1   (one) first highlighted chunk

+

+ [ + ] +   prev/next file +

+

+ u   back to the index +

+

+ ?   show/hide this help +

@@ -53,6 +64,10 @@

+ + + + @@ -63,8 +78,13 @@

diff --git a/tests/gold/html/omit_3/main_py.html b/tests/gold/html/omit_3/main_py.html index c51dc5ced..3d44172d8 100644 --- a/tests/gold/html/omit_3/main_py.html +++ b/tests/gold/html/omit_3/main_py.html @@ -39,6 +39,17 @@

1   (one) first highlighted chunk

+

+ [ + ] +   prev/next file +

+

+ u   back to the index +

+

+ ?   show/hide this help +

@@ -53,6 +64,10 @@

+ + + + @@ -71,8 +86,13 @@

diff --git a/tests/gold/html/omit_4/index.html b/tests/gold/html/omit_4/index.html index 5497b331e..7474f45aa 100644 --- a/tests/gold/html/omit_4/index.html +++ b/tests/gold/html/omit_4/index.html @@ -28,6 +28,14 @@

Coverage report: x c   change column sorting

+

+ [ + ] +   prev/next file +

+

+ ?   show/hide this help +

@@ -87,9 +95,18 @@

Coverage report: diff --git a/tests/gold/html/omit_4/m1_py.html b/tests/gold/html/omit_4/m1_py.html index 761819180..f8addaca3 100644 --- a/tests/gold/html/omit_4/m1_py.html +++ b/tests/gold/html/omit_4/m1_py.html @@ -39,6 +39,17 @@

1   (one) first highlighted chunk

+

+ [ + ] +   prev/next file +

+

+ u   back to the index +

+

+ ?   show/hide this help +

@@ -53,6 +64,10 @@

+ + + + @@ -63,8 +78,13 @@

diff --git a/tests/gold/html/omit_4/m3_py.html b/tests/gold/html/omit_4/m3_py.html index 9cf26e2e0..cd16fc3fb 100644 --- a/tests/gold/html/omit_4/m3_py.html +++ b/tests/gold/html/omit_4/m3_py.html @@ -39,6 +39,17 @@

1   (one) first highlighted chunk

+

+ [ + ] +   prev/next file +

+

+ u   back to the index +

+

+ ?   show/hide this help +

@@ -53,6 +64,10 @@

+ + + + @@ -63,8 +78,13 @@

diff --git a/tests/gold/html/omit_4/main_py.html b/tests/gold/html/omit_4/main_py.html index c51dc5ced..3d44172d8 100644 --- a/tests/gold/html/omit_4/main_py.html +++ b/tests/gold/html/omit_4/main_py.html @@ -39,6 +39,17 @@

1   (one) first highlighted chunk

+

+ [ + ] +   prev/next file +

+

+ u   back to the index +

+

+ ?   show/hide this help +

@@ -53,6 +64,10 @@

+ + + + @@ -71,8 +86,13 @@

diff --git a/tests/gold/html/omit_5/index.html b/tests/gold/html/omit_5/index.html index 251e54981..4fa3382ef 100644 --- a/tests/gold/html/omit_5/index.html +++ b/tests/gold/html/omit_5/index.html @@ -28,6 +28,14 @@

Coverage report: x c   change column sorting

+

+ [ + ] +   prev/next file +

+

+ ?   show/hide this help +

@@ -80,9 +88,18 @@

Coverage report: diff --git a/tests/gold/html/omit_5/m1_py.html b/tests/gold/html/omit_5/m1_py.html index 761819180..2c5341330 100644 --- a/tests/gold/html/omit_5/m1_py.html +++ b/tests/gold/html/omit_5/m1_py.html @@ -39,6 +39,17 @@

1   (one) first highlighted chunk

+

+ [ + ] +   prev/next file +

+

+ u   back to the index +

+

+ ?   show/hide this help +

@@ -53,6 +64,10 @@

+ + + + @@ -63,8 +78,13 @@

diff --git a/tests/gold/html/omit_5/main_py.html b/tests/gold/html/omit_5/main_py.html index c51dc5ced..a6ac2f9d9 100644 --- a/tests/gold/html/omit_5/main_py.html +++ b/tests/gold/html/omit_5/main_py.html @@ -39,6 +39,17 @@

1   (one) first highlighted chunk

+

+ [ + ] +   prev/next file +

+

+ u   back to the index +

+

+ ?   show/hide this help +

@@ -53,6 +64,10 @@

+ + + + @@ -71,8 +86,13 @@

diff --git a/tests/gold/html/other/blah_blah_other_py.html b/tests/gold/html/other/blah_blah_other_py.html index 4da153cdd..abe91136b 100644 --- a/tests/gold/html/other/blah_blah_other_py.html +++ b/tests/gold/html/other/blah_blah_other_py.html @@ -3,7 +3,7 @@ - Coverage for /private/var/folders/10/4sn2sk3j2mg5m116f08_367m0000gq/T/pytest-of-nedbatchelder/pytest-1363/popen-gw2/t48/othersrc/other.py: 100% + Coverage for /private/var/folders/vh/wwf6sk0j6ylg5397jq_3cv5w0000gp/T/pytest-of-jmft2/pytest-2/popen-gw3/t101/othersrc/other.py: 100% @@ -12,7 +12,7 @@

- Coverage for /private/var/folders/10/4sn2sk3j2mg5m116f08_367m0000gq/T/pytest-of-nedbatchelder/pytest-1363/popen-gw2/t48/othersrc/other.py: + Coverage for /private/var/folders/vh/wwf6sk0j6ylg5397jq_3cv5w0000gp/T/pytest-of-jmft2/pytest-2/popen-gw3/t101/othersrc/other.py: 100%

@@ -39,6 +39,17 @@

1   (one) first highlighted chunk

+

+ [ + ] +   prev/next file +

+

+ u   back to the index +

+

+ ?   show/hide this help +

@@ -53,6 +64,10 @@

+ + + +

@@ -65,8 +80,13 @@

diff --git a/tests/gold/html/other/here_py.html b/tests/gold/html/other/here_py.html index 36dbd4cf8..284db5f72 100644 --- a/tests/gold/html/other/here_py.html +++ b/tests/gold/html/other/here_py.html @@ -39,6 +39,17 @@

1   (one) first highlighted chunk

+

+ [ + ] +   prev/next file +

+

+ u   back to the index +

+

+ ?   show/hide this help +

@@ -53,6 +64,10 @@

+ + + + @@ -67,8 +82,13 @@

diff --git a/tests/gold/html/other/index.html b/tests/gold/html/other/index.html index 11a546970..3dcc1e73a 100644 --- a/tests/gold/html/other/index.html +++ b/tests/gold/html/other/index.html @@ -28,6 +28,14 @@

Coverage report: x c   change column sorting

+

+ [ + ] +   prev/next file +

+

+ ?   show/hide this help +

@@ -49,7 +57,7 @@

Coverage report: - /private/var/folders/10/4sn2sk3j2mg5m116f08_367m0000gq/T/pytest-of-nedbatchelder/pytest-964/popen-gw6/t104/othersrc/other.py + /private/var/folders/vh/wwf6sk0j6ylg5397jq_3cv5w0000gp/T/pytest-of-jmft2/pytest-2/popen-gw3/t101/othersrc/other.py 1 0 0 @@ -80,9 +88,18 @@

Coverage report: diff --git a/tests/gold/html/partial/index.html b/tests/gold/html/partial/index.html index 91cb580ab..29a5c6f3e 100644 --- a/tests/gold/html/partial/index.html +++ b/tests/gold/html/partial/index.html @@ -30,6 +30,14 @@

Coverage report: p c   change column sorting

+

+ [ + ] +   prev/next file +

+

+ ?   show/hide this help +

@@ -81,9 +89,18 @@

Coverage report: diff --git a/tests/gold/html/partial/partial_py.html b/tests/gold/html/partial/partial_py.html index fd53f940f..48367c812 100644 --- a/tests/gold/html/partial/partial_py.html +++ b/tests/gold/html/partial/partial_py.html @@ -40,6 +40,17 @@

1   (one) first highlighted chunk

+

+ [ + ] +   prev/next file +

+

+ u   back to the index +

+

+ ?   show/hide this help +

@@ -55,6 +66,10 @@

+ + + + @@ -80,8 +95,13 @@

diff --git a/tests/gold/html/styled/a_py.html b/tests/gold/html/styled/a_py.html index 4e54370b9..0e22926d5 100644 --- a/tests/gold/html/styled/a_py.html +++ b/tests/gold/html/styled/a_py.html @@ -40,6 +40,17 @@

1   (one) first highlighted chunk

+

+ [ + ] +   prev/next file +

+

+ u   back to the index +

+

+ ?   show/hide this help +

@@ -54,6 +65,10 @@

+ + + + @@ -67,8 +82,13 @@

diff --git a/tests/gold/html/styled/index.html b/tests/gold/html/styled/index.html index 45b28367d..894e3870a 100644 --- a/tests/gold/html/styled/index.html +++ b/tests/gold/html/styled/index.html @@ -29,6 +29,14 @@

Coverage report: x c   change column sorting

+

+ [ + ] +   prev/next file +

+

+ ?   show/hide this help +

@@ -74,9 +82,18 @@

Coverage report: diff --git a/tests/gold/html/unicode/index.html b/tests/gold/html/unicode/index.html index 722099c38..1881a3ff2 100644 --- a/tests/gold/html/unicode/index.html +++ b/tests/gold/html/unicode/index.html @@ -28,6 +28,14 @@

Coverage report: x c   change column sorting

+

+ [ + ] +   prev/next file +

+

+ ?   show/hide this help +

@@ -73,9 +81,18 @@

Coverage report: diff --git a/tests/gold/html/unicode/unicode_py.html b/tests/gold/html/unicode/unicode_py.html index 79bebcc90..3d34f8dac 100644 --- a/tests/gold/html/unicode/unicode_py.html +++ b/tests/gold/html/unicode/unicode_py.html @@ -39,6 +39,17 @@

1   (one) first highlighted chunk

+

+ [ + ] +   prev/next file +

+

+ u   back to the index +

+

+ ?   show/hide this help +

@@ -53,6 +64,10 @@

+ + + + @@ -66,8 +81,13 @@

From 66c7778bd8e15ed61d0d7668a5eab152707e2105 Mon Sep 17 00:00:00 2001 From: "J. M. F. Tsang" Date: Mon, 25 Apr 2022 21:59:38 +0100 Subject: [PATCH 5/7] Handle case in loop where there are no files generated --- coverage/html.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/coverage/html.py b/coverage/html.py index 7f60b8abc..783f5c890 100644 --- a/coverage/html.py +++ b/coverage/html.py @@ -223,10 +223,12 @@ def report(self, morfs): self.first_fr = fr pluprev_fr, prev_fr, prev_analysis = prev_fr, fr, analysis - # One more iteration for the final file. - self.html_file(prev_fr, prev_analysis, pluprev_fr, None) - # This is the last file processed - self.final_fr = prev_fr + # One more iteration for the final file. (Or not, if there are + # no files at all.) + if prev_fr is not None: + self.html_file(prev_fr, prev_analysis, pluprev_fr, None) + # This is the last file processed + self.final_fr = prev_fr if not self.all_files_nums: raise NoDataError("No data to report.") From 8f047fdf7fd23e08808740d2144b91f1dfaffd6d Mon Sep 17 00:00:00 2001 From: "J. M. F. Tsang" Date: Mon, 25 Apr 2022 22:09:47 +0100 Subject: [PATCH 6/7] Remove extraneous print statement --- coverage/html.py | 1 - 1 file changed, 1 deletion(-) diff --git a/coverage/html.py b/coverage/html.py index 783f5c890..dcbec30bc 100644 --- a/coverage/html.py +++ b/coverage/html.py @@ -273,7 +273,6 @@ def html_file(self, fr, analysis, prev_fr=None, next_fr=None): else: next_html = "index.html" - print(prev_html, html_filename, next_html) ensure_dir(self.directory) if not os.listdir(self.directory): self.directory_was_empty = True From 1b9ba338c2a0342a14bc5c7a7340883642158521 Mon Sep 17 00:00:00 2001 From: "J. M. F. Tsang" Date: Mon, 25 Apr 2022 22:33:20 +0100 Subject: [PATCH 7/7] Fixed gold files for partial_626 --- tests/gold/html/partial_626/index.html | 17 ++++++++++++++++ tests/gold/html/partial_626/partial_py.html | 22 ++++++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/tests/gold/html/partial_626/index.html b/tests/gold/html/partial_626/index.html index 3814352e7..e99e683ca 100644 --- a/tests/gold/html/partial_626/index.html +++ b/tests/gold/html/partial_626/index.html @@ -30,6 +30,14 @@

Coverage report: p c   change column sorting

+

+ [ + ] +   prev/next file +

+

+ ?   show/hide this help +

@@ -85,6 +93,15 @@

Coverage report: created at 2021-10-23 17:18 -0400

+
+

+ first file + final file +

+ + + +
diff --git a/tests/gold/html/partial_626/partial_py.html b/tests/gold/html/partial_626/partial_py.html index 3ed0dc727..fade2b248 100644 --- a/tests/gold/html/partial_626/partial_py.html +++ b/tests/gold/html/partial_626/partial_py.html @@ -40,6 +40,17 @@

1   (one) first highlighted chunk

+

+ [ + ] +   prev/next file +

+

+ u   back to the index +

+

+ ?   show/hide this help +

@@ -55,6 +66,10 @@

+ + + + @@ -80,7 +95,12 @@