diff options
-rw-r--r-- | tests/gold/html/partial_626/index.html | 93 | ||||
-rw-r--r-- | tests/gold/html/partial_626/partial_py.html | 83 | ||||
-rw-r--r-- | tests/test_html.py | 50 |
3 files changed, 210 insertions, 16 deletions
diff --git a/tests/gold/html/partial_626/index.html b/tests/gold/html/partial_626/index.html new file mode 100644 index 00000000..f1b1465e --- /dev/null +++ b/tests/gold/html/partial_626/index.html @@ -0,0 +1,93 @@ +<!DOCTYPE html> +<html> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> + <title>Coverage report</title> + <link rel="icon" sizes="32x32" href="favicon_32.png"> + <link rel="stylesheet" href="style.css" type="text/css"> + <script type="text/javascript" src="jquery.min.js"></script> + <script type="text/javascript" src="jquery.ba-throttle-debounce.min.js"></script> + <script type="text/javascript" src="jquery.tablesorter.min.js"></script> + <script type="text/javascript" src="jquery.hotkeys.js"></script> + <script type="text/javascript" src="coverage_html.js"></script> + <script type="text/javascript"> + jQuery(document).ready(coverage.index_ready); + </script> +</head> +<body class="indexfile"> +<div id="header"> + <div class="content"> + <h1>Coverage report: + <span class="pc_cov">87%</span> + </h1> + <img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" /> + <form id="filter_container"> + <input id="filter" type="text" value="" placeholder="filter..." /> + </form> + </div> +</div> +<div class="help_panel"> + <img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" /> + <p class="legend">Hot-keys on this page</p> + <div> + <p class="keyhelp"> + <span class="key">n</span> + <span class="key">s</span> + <span class="key">m</span> + <span class="key">x</span> + <span class="key">b</span> + <span class="key">p</span> + <span class="key">c</span> change column sorting + </p> + </div> +</div> +<div id="index"> + <table class="index"> + <thead> + <tr class="tablehead" title="Click to sort"> + <th class="name left headerSortDown shortkey_n">Module</th> + <th class="shortkey_s">statements</th> + <th class="shortkey_m">missing</th> + <th class="shortkey_x">excluded</th> + <th class="shortkey_b">branches</th> + <th class="shortkey_p">partial</th> + <th class="right shortkey_c">coverage</th> + </tr> + </thead> + <tfoot> + <tr class="total"> + <td class="name left">Total</td> + <td>9</td> + <td>0</td> + <td>1</td> + <td>6</td> + <td>2</td> + <td class="right" data-ratio="13 15">87%</td> + </tr> + </tfoot> + <tbody> + <tr class="file"> + <td class="name left"><a href="partial_py.html">partial.py</a></td> + <td>9</td> + <td>0</td> + <td>1</td> + <td>6</td> + <td>2</td> + <td class="right" data-ratio="13 15">87%</td> + </tr> + </tbody> + </table> + <p id="no_rows"> + No items found using the specified filter. + </p> +</div> +<div id="footer"> + <div class="content"> + <p> + <a class="nav" href="https://coverage.readthedocs.io/en/coverage-5.3.2a0">coverage.py v5.3.2a0</a>, + created at 2021-01-07 09:43 -0500 + </p> + </div> +</div> +</body> +</html> diff --git a/tests/gold/html/partial_626/partial_py.html b/tests/gold/html/partial_626/partial_py.html new file mode 100644 index 00000000..adb0aaf0 --- /dev/null +++ b/tests/gold/html/partial_626/partial_py.html @@ -0,0 +1,83 @@ +<!DOCTYPE html> +<html> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> + <meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" /> + <title>Coverage for partial.py: 87%</title> + <link rel="icon" sizes="32x32" href="favicon_32.png"> + <link rel="stylesheet" href="style.css" type="text/css"> + <script type="text/javascript" src="jquery.min.js"></script> + <script type="text/javascript" src="jquery.hotkeys.js"></script> + <script type="text/javascript" src="jquery.isonscreen.js"></script> + <script type="text/javascript" src="coverage_html.js"></script> + <script type="text/javascript"> + jQuery(document).ready(coverage.pyfile_ready); + </script> +</head> +<body class="pyfile"> +<div id="header"> + <div class="content"> + <h1>Coverage for <b>partial.py</b> : + <span class="pc_cov">87%</span> + </h1> + <img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" /> + <h2 class="stats"> + 9 statements + <button type="button" class="run shortkey_r button_toggle_run" title="Toggle lines run">9 run</button> + <button type="button" class="mis show_mis shortkey_m button_toggle_mis" title="Toggle lines missing">0 missing</button> + <button type="button" class="exc show_exc shortkey_x button_toggle_exc" title="Toggle lines excluded">1 excluded</button> + <button type="button" class="par run show_par shortkey_p button_toggle_par" title="Toggle lines partially run">2 partial</button> + </h2> + </div> +</div> +<div class="help_panel"> + <img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" /> + <p class="legend">Hot-keys on this page</p> + <div> + <p class="keyhelp"> + <span class="key">r</span> + <span class="key">m</span> + <span class="key">x</span> + <span class="key">p</span> toggle line displays + </p> + <p class="keyhelp"> + <span class="key">j</span> + <span class="key">k</span> next/prev highlighted chunk + </p> + <p class="keyhelp"> + <span class="key">0</span> (zero) top of page + </p> + <p class="keyhelp"> + <span class="key">1</span> (one) first highlighted chunk + </p> + </div> +</div> +<div id="source"> + <p id="t1" class="pln"><span class="n"><a href="#t1">1</a></span><span class="t"><span class="com"># partial branches and excluded lines</span> </span><span class="r"></span></p> + <p id="t2" class="run"><span class="n"><a href="#t2">2</a></span><span class="t"><span class="nam">a</span> <span class="op">=</span> <span class="num">2</span> </span><span class="r"></span></p> + <p id="t3" class="pln"><span class="n"><a href="#t3">3</a></span><span class="t"> </span><span class="r"></span></p> + <p id="t4" class="par run show_par"><span class="n"><a href="#t4">4</a></span><span class="t"><span class="key">while</span> <span class="str">"no peephole"</span><span class="op">.</span><span class="nam">upper</span><span class="op">(</span><span class="op">)</span><span class="op">:</span> <span class="com"># t4</span> </span><span class="r"><span class="annotate short">4 ↛ 7</span><span class="annotate long">line 4 didn't jump to line 7, because the condition on line 4 was never false</span></span></p> + <p id="t5" class="run"><span class="n"><a href="#t5">5</a></span><span class="t"> <span class="key">break</span> </span><span class="r"></span></p> + <p id="t6" class="pln"><span class="n"><a href="#t6">6</a></span><span class="t"> </span><span class="r"></span></p> + <p id="t7" class="run"><span class="n"><a href="#t7">7</a></span><span class="t"><span class="key">while</span> <span class="nam">a</span><span class="op">:</span> <span class="com"># pragma: no branch</span> </span><span class="r"></span></p> + <p id="t8" class="run"><span class="n"><a href="#t8">8</a></span><span class="t"> <span class="key">break</span> </span><span class="r"></span></p> + <p id="t9" class="pln"><span class="n"><a href="#t9">9</a></span><span class="t"> </span><span class="r"></span></p> + <p id="t10" class="run"><span class="n"><a href="#t10">10</a></span><span class="t"><span class="key">if</span> <span class="num">0</span><span class="op">:</span> </span><span class="r"></span></p> + <p id="t11" class="pln"><span class="n"><a href="#t11">11</a></span><span class="t"> <span class="nam">never_happen</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p id="t12" class="pln"><span class="n"><a href="#t12">12</a></span><span class="t"> </span><span class="r"></span></p> + <p id="t13" class="par run show_par"><span class="n"><a href="#t13">13</a></span><span class="t"><span class="key">if</span> <span class="num">13</span><span class="op">:</span> </span><span class="r"><span class="annotate short">13 ↛ 16</span><span class="annotate long">line 13 didn't jump to line 16, because the condition on line 13 was never false</span></span></p> + <p id="t14" class="run"><span class="n"><a href="#t14">14</a></span><span class="t"> <span class="nam">a</span> <span class="op">=</span> <span class="num">14</span> </span><span class="r"></span></p> + <p id="t15" class="pln"><span class="n"><a href="#t15">15</a></span><span class="t"> </span><span class="r"></span></p> + <p id="t16" class="run"><span class="n"><a href="#t16">16</a></span><span class="t"><span class="key">if</span> <span class="nam">a</span> <span class="op">==</span> <span class="num">16</span><span class="op">:</span> </span><span class="r"></span></p> + <p id="t17" class="exc show_exc"><span class="n"><a href="#t17">17</a></span><span class="t"> <span class="key">raise</span> <span class="nam">ZeroDivisionError</span><span class="op">(</span><span class="str">"17"</span><span class="op">)</span> </span><span class="r"></span></p> +</div> +<div id="footer"> + <div class="content"> + <p> + <a class="nav" href="index.html">« index</a> <a class="nav" href="https://coverage.readthedocs.io/en/coverage-5.3.2a0">coverage.py v5.3.2a0</a>, + created at 2021-01-07 09:43 -0500 + </p> + </div> +</div> +</body> +</html> diff --git a/tests/test_html.py b/tests/test_html.py index 85f08204..3eeb607a 100644 --- a/tests/test_html.py +++ b/tests/test_html.py @@ -938,23 +938,41 @@ assert len(math) == 18 cov = coverage.Coverage(config_file="partial.ini") partial = self.start_import_stop(cov, "partial") - cov.html_report(partial, directory="out/partial") - compare_html(gold_path("html/partial"), "out/partial") - contains( - "out/partial/partial_py.html", - '<p id="t4" class="par run show_par">', - '<p id="t7" class="run">', - # The "if 0" and "if 1" statements are optimized away. - '<p id="t10" class="pln">', - # The "raise ZeroDivisionError" is excluded by regex in the .ini. - '<p id="t17" class="exc show_exc">', - ) - contains( - "out/partial/index.html", - '<a href="partial_py.html">partial.py</a>', - '<span class="pc_cov">91%</span>' - ) + if env.PYBEHAVIOR.pep626: + cov.html_report(partial, directory="out/partial_626") + compare_html(gold_path("html/partial_626"), "out/partial_626") + contains( + "out/partial_626/partial_py.html", + '<p id="t4" class="par run show_par">', + '<p id="t7" class="run">', + # The "if 0" and "if 1" statements are marked as run. + '<p id="t10" class="run">', + # The "raise ZeroDivisionError" is excluded by regex in the .ini. + '<p id="t17" class="exc show_exc">', + ) + contains( + "out/partial_626/index.html", + '<a href="partial_py.html">partial.py</a>', + '<span class="pc_cov">87%</span>' + ) + else: + cov.html_report(partial, directory="out/partial") + compare_html(gold_path("html/partial"), "out/partial") + contains( + "out/partial/partial_py.html", + '<p id="t4" class="par run show_par">', + '<p id="t7" class="run">', + # The "if 0" and "if 1" statements are optimized away. + '<p id="t10" class="pln">', + # The "raise ZeroDivisionError" is excluded by regex in the .ini. + '<p id="t17" class="exc show_exc">', + ) + contains( + "out/partial/index.html", + '<a href="partial_py.html">partial.py</a>', + '<span class="pc_cov">91%</span>' + ) def test_styled(self): self.make_file("a.py", """\ |