[diffoscope] 02/02: tests: Add tests for HTML output.

Chris Lamb chris at chris-lamb.co.uk
Sat Jan 21 12:16:35 CET 2017


This is an automated email from the git hooks/post-receive script.

lamby pushed a commit to branch master
in repository diffoscope.

commit 15ca1293d8c955821c98fa2e56ca4177ce73373c
Author: Chris Lamb <lamby at debian.org>
Date:   Sat Jan 21 22:11:56 2017 +1100

    tests: Add tests for HTML output.
    
    Signed-off-by: Chris Lamb <lamby at debian.org>
---
 tests/data/index.html    | 154 +++++++++++++++++++++
 tests/data/output.html   | 348 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/test_presenters.py |  21 ++-
 3 files changed, 520 insertions(+), 3 deletions(-)

diff --git a/tests/data/index.html b/tests/data/index.html
new file mode 100644
index 0000000..82766c9
--- /dev/null
+++ b/tests/data/index.html
@@ -0,0 +1,154 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <meta charset="utf-8" />
+  <meta http-equiv="x-ua-compatible" content="IE=edge">
+  <meta name="referrer" content="no-referrer" />
+  <meta name="generator" content="diffoscope" />
+  <link rel="icon" type="image/png" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAADdgAAA3YBfdWCzAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAM8SURBVFiF7dZdaJZlGAfw3/O+e9XNjy3XllZzWImBxIpifqTgsmUHBSIeBNFBdRh0UHQ0xGdb66CFBIERZEFRQRRUw0HkQkLMYQSBdpCFWdgSP6jpNn2393k68Nn2bj3vXtb6UOh/cl/39b/u67mem/913zf/4z9GUDw5xNI8n5WIzW9m/QF2YluJmI8203mALzEvLWAerRs4Pz6vSIkZSlsYk0/GkaB0zEgyDgWMlijyWsJuS2fkQwu8pqpMTA0ypeiShG71Bp0rU8Q+A47MWEDg [...]
+  <title>/usr/bin/pytest-3 -vv -r sxX tests/test_main.py tests/test_presenters.py</title>
+  <style type="text/css">
+    body.diffoscope {
+      background: white;
+      color: black;
+    }
+    .diffoscope .footer {
+      font-size: small;
+    }
+    .diffoscope .difference {
+      border: outset #888 1px;
+      background: #E8E8E8;
+      background: rgba(0,0,0,.1);
+      padding: 0.5em;
+      margin: 0.5em 0;
+    }
+    .diffoscope .difference table {
+      table-layout: fixed;
+      width: 100%;
+      border: 0;
+    }
+    .diffoscope .difference th,
+    .diffoscope .difference td {
+      border: 0;
+    }
+    .diffoscope table.diff {
+      border: 0;
+      border-collapse:collapse;
+      font-size:0.75em;
+      font-family: 'Lucida Console', monospace;
+    }
+    .diffoscope table.diff tr:hover td {
+      background: #FFFF00;
+    }
+    .diffoscope .line {
+      color:#8080a0
+    }
+    .diffoscope th {
+      background: black;
+      color: white
+    }
+    .diffoscope .diffunmodified td {
+      background: #D0D0E0
+    }
+    .diffoscope .diffhunk td {
+      background: #A0A0A0
+    }
+    .diffoscope .diffadded td {
+      background: #CCFFCC
+    }
+    .diffoscope .diffdeleted td {
+      background: #FFCCCC
+    }
+    .diffoscope .diffchanged td {
+      background: #FFFFA0
+    }
+    .diffoscope ins, del {
+      background: #E0C880;
+      text-decoration: none
+    }
+    .diffoscope .diffponct {
+      color: #B08080
+    }
+    .diffoscope .comment {
+      font-style: italic;
+    }
+    .diffoscope .source {
+      font-weight: bold;
+    }
+    .diffoscope .error {
+      border: solid black 1px;
+      background: red;
+      color: white;
+      padding: 0.2em;
+    }
+    .diffoscope .anchor {
+      margin-left: 0.5em;
+      font-size: 80%;
+      color: #333;
+      text-decoration: none;
+      display: none;
+    }
+    .diffoscope .diffheader:hover .anchor {
+      display: inline;
+    }
+    .diffoscope table.diff tr.ondemand td {
+      background: #f99;
+      text-align: center;
+      padding: 0.5em 0;
+    }
+    .diffoscope table.diff tr.ondemand:hover td {
+      background: #faa;
+      cursor: pointer;
+    }
+    .diffoscope .diffcontrol {
+      float: left;
+      margin-right: 0.3em;
+      cursor: pointer;
+      display: none; /* currently, only available in html-dir output where jquery is enabled */
+    }
+    .diffoscope .diffcontrol-double {
+      line-height: 200%;
+    }
+    .diffoscope .colines {
+      width: 3em;
+    }
+    .diffoscope .coldiff {
+      width: 99%;
+    }
+  </style>
+  
+</head>
+<body class="diffoscope">
+<div class="difference"><div class="diffheader"><div class="diffcontrol diffcontrol-double">[−]</div><div><span class="source">test1.tar</span> vs.</div><div><span class="source">test2.tar</span> <a class="anchor" href="#" name="">¶</a></div></div><div class="difference"><div class="diffheader"><div class="diffcontrol">[−]</div><div><span class="source">file list</span> <a class="anchor" href="#file-list" name="file-list">¶</a></div></div><table class="diff">
+<colgroup><col class="colines"/><col class="coldiff"/>
+<col class="colines"/><col class="coldiff"/></colgroup>
+<tr class="diffhunk"><td colspan="2">Offset 1, 4 lines modified</td><td colspan="2">Offset 1, 4 lines modified</td></tr>
+<tr class="diffchanged"><td class="diffline">1 </td><td class="diffpresent">drwxr-​xr-​x<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​0<span class="diffponct">·</span>​lunar<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​(1000)​<span class="diffponct">·</span>​lunar<span class="diffponct">·</span>​<span class="diffponct" [...]
+<tr class="diffchanged"><td class="diffline">2 </td><td class="diffpresent">-​rw-​r-​-​r-​-​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​0<span class="diffponct">·</span>​lunar<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​(1000)​<span class="diffponct">·</span>​lunar<span class="diffponct">·</span>​<span class="diffpo [...]
+<tr class="diffchanged"><td class="diffline">3 </td><td class="diffpresent">crw-​r-​-​r-​-​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​0<span class="diffponct">·</span>​root<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​ [...]
+<tr class="diffchanged"><td class="diffline">4 </td><td class="diffpresent">lrwxrwxrwx<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​0<span class="diffponct">·</span>​lunar<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​(1000)​<span class="diffponct">·</span>​lunar<span class="diffponct">·</span>​<span class="diffponct">· [...]
+</table></div><div class="difference"><div class="diffheader"><div class="diffcontrol">[−]</div><div><span class="source">dir/text</span> <a class="anchor" href="#dir-text" name="dir-text">¶</a></div></div><table class="diff">
+<colgroup><col class="colines"/><col class="coldiff"/>
+<col class="colines"/><col class="coldiff"/></colgroup>
+<tr class="diffhunk"><td colspan="2">Offset 1, 6 lines modified</td><td colspan="2">Offset 1, 12 lines modified</td></tr>
+<tr class="diffadded"><td colspan="2"> </td><td class="diffline">1 </td><td class="diffpresent">A<span class="diffponct">·</span>​common<span class="diffponct">·</span>​form<span class="diffponct">·</span>​of<span class="diffponct">·</span>​lorem<span class="diffponct">·</span>​ipsum<span class="diffponct">·</span>​reads:​</td></tr>
+<tr class="diffadded"><td colspan="2"> </td><td colspan="2"> </td></tr>
+<tr class="diffunmodified"><td class="diffline">1 </td><td class="diffpresent">Lorem<span class="diffponct">·</span>​ipsum<span class="diffponct">·</span>​dolor<span class="diffponct">·</span>​sit<span class="diffponct">·</span>​amet,​<span class="diffponct">·</span>​consectetur<span class="diffponct">·</span>​adipiscing<span class="diffponct">·</span>​elit,​<span class="diffponct">·</span>​sed<span class="diffponct">·</span>​do<span class="diffponct">·</span>​eiusmod<span class="diffpon [...]
+<tr class="diffunmodified"><td class="diffline">2 </td><td class="diffpresent">incididunt<span class="diffponct">·</span>​ut<span class="diffponct">·</span>​labore<span class="diffponct">·</span>​et<span class="diffponct">·</span>​dolore<span class="diffponct">·</span>​magna<span class="diffponct">·</span>​aliqua.​<span class="diffponct">·</span>​Ut<span class="diffponct">·</span>​enim<span class="diffponct">·</span>​ad<span class="diffponct">·</span>​minim<span class="diffponct">·</span [...]
+<tr class="diffunmodified"><td class="diffline">3 </td><td class="diffpresent">nostrud<span class="diffponct">·</span>​exercitation<span class="diffponct">·</span>​ullamco<span class="diffponct">·</span>​laboris<span class="diffponct">·</span>​nisi<span class="diffponct">·</span>​ut<span class="diffponct">·</span>​aliquip<span class="diffponct">·</span>​ex<span class="diffponct">·</span>​ea<span class="diffponct">·</span>​commodo<span class="diffponct">·</span>​consequat.​</td><td class= [...]
+<tr class="diffunmodified"><td class="diffline">4 </td><td class="diffpresent">Duis<span class="diffponct">·</span>​aute<span class="diffponct">·</span>​irure<span class="diffponct">·</span>​dolor<span class="diffponct">·</span>​in<span class="diffponct">·</span>​reprehenderit<span class="diffponct">·</span>​in<span class="diffponct">·</span>​voluptate<span class="diffponct">·</span>​velit<span class="diffponct">·</span>​esse<span class="diffponct">·</span>​cillum<span class="diffponct"> [...]
+<tr class="diffunmodified"><td class="diffline">5 </td><td class="diffpresent">fugiat<span class="diffponct">·</span>​nulla<span class="diffponct">·</span>​pariatur.​<span class="diffponct">·</span>​Excepteur<span class="diffponct">·</span>​sint<span class="diffponct">·</span>​occaecat<span class="diffponct">·</span>​cupidatat<span class="diffponct">·</span>​non<span class="diffponct">·</span>​proident,​<span class="diffponct">·</span>​sunt<span class="diffponct">·</span>​in</td><td clas [...]
+<tr class="diffunmodified"><td class="diffline">6 </td><td class="diffpresent">culpa<span class="diffponct">·</span>​qui<span class="diffponct">·</span>​officia<span class="diffponct">·</span>​deserunt<span class="diffponct">·</span>​mollit<span class="diffponct">·</span>​anim<span class="diffponct">·</span>​id<span class="diffponct">·</span>​est<span class="diffponct">·</span>​laborum.​</td><td class="diffline">7 </td><td class="diffpresent">culpa<span class="diffponct">·</span>​qui<spa [...]
+<tr class="diffadded"><td colspan="2"> </td><td colspan="2"> </td></tr>
+<tr class="diffadded"><td colspan="2"> </td><td class="diffline">8 </td><td class="diffpresent">"Lorem<span class="diffponct">·</span>​ipsum"<span class="diffponct">·</span>​text<span class="diffponct">·</span>​is<span class="diffponct">·</span>​derived<span class="diffponct">·</span>​from<span class="diffponct">·</span>​sections<span class="diffponct">·</span>​1.​10.​32-​-​3<span class="diffponct">·</span>​of<span class="diffponct">·</span>​Cicero&#x27;s<span class="diffponct" [...]
+<tr class="diffadded"><td colspan="2"> </td><td class="diffline">9 </td><td class="diffpresent">bonorum<span class="diffponct">·</span>​et<span class="diffponct">·</span>​malorum<span class="diffponct">·</span>​(On<span class="diffponct">·</span>​the<span class="diffponct">·</span>​Ends<span class="diffponct">·</span>​of<span class="diffponct">·</span>​Goods<span class="diffponct">·</span>​and<span class="diffponct">·</span>​Evils,​<span class="diffponct">·</span>​or<span class="diffponc [...]
+<tr class="diffadded"><td colspan="2"> </td><td class="diffline">10 </td><td class="diffpresent">The<span class="diffponct">·</span>​Purposes<span class="diffponct">·</span>​of<span class="diffponct">·</span>​Good<span class="diffponct">·</span>​and<span class="diffponct">·</span>​Evil)​.​</td></tr>
+</table></div><div class="difference"><div class="diffheader"><div class="diffcontrol">[−]</div><div><span class="source">dir/link</span> <a class="anchor" href="#dir-link" name="dir-link">¶</a></div><div class="comment">symlink</div></div><table class="diff">
+<colgroup><col class="colines"/><col class="coldiff"/>
+<col class="colines"/><col class="coldiff"/></colgroup>
+<tr class="diffhunk"><td colspan="2">Offset 1, 1 lines modified</td><td colspan="2">Offset 1, 1 lines modified</td></tr>
+<tr class="diffchanged"><td class="diffline">1 </td><td class="diffpresent">destination:​<span class="diffponct">·</span>​broken</td><td class="diffline">1 </td><td class="diffpresent">destination:​<span class="diffponct">·</span>​<ins>really-​</ins>broken</td></tr>
+</table></div></div>
+<div class="footer">Generated by <a href="https://diffoscope.org" rel="noopener noreferrer" target="_blank">diffoscope</a> 69</div>
+</body>
+</html>
diff --git a/tests/data/output.html b/tests/data/output.html
new file mode 100644
index 0000000..7d0ca31
--- /dev/null
+++ b/tests/data/output.html
@@ -0,0 +1,348 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <meta charset="utf-8" />
+  <meta http-equiv="x-ua-compatible" content="IE=edge">
+  <meta name="referrer" content="no-referrer" />
+  <meta name="generator" content="diffoscope" />
+  <link rel="icon" type="image/png" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAADdgAAA3YBfdWCzAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAM8SURBVFiF7dZdaJZlGAfw3/O+e9XNjy3XllZzWImBxIpifqTgsmUHBSIeBNFBdRh0UHQ0xGdb66CFBIERZEFRQRRUw0HkQkLMYQSBdpCFWdgSP6jpNn2393k68Nn2bj3vXtb6UOh/cl/39b/u67mem/913zf/4z9GUDw5xNI8n5WIzW9m/QF2YluJmI8203mALzEvLWAerRs4Pz6vSIkZSlsYk0/GkaB0zEgyDgWMlijyWsJuS2fkQwu8pqpMTA0ypeiShG71Bp0rU8Q+A47MWEDg [...]
+  <title>/usr/bin/pytest-3 -vv -r sxX tests/test_main.py tests/test_presenters.py</title>
+  <style type="text/css">
+    body.diffoscope {
+      background: white;
+      color: black;
+    }
+    .diffoscope .footer {
+      font-size: small;
+    }
+    .diffoscope .difference {
+      border: outset #888 1px;
+      background: #E8E8E8;
+      background: rgba(0,0,0,.1);
+      padding: 0.5em;
+      margin: 0.5em 0;
+    }
+    .diffoscope .difference table {
+      table-layout: fixed;
+      width: 100%;
+      border: 0;
+    }
+    .diffoscope .difference th,
+    .diffoscope .difference td {
+      border: 0;
+    }
+    .diffoscope table.diff {
+      border: 0;
+      border-collapse:collapse;
+      font-size:0.75em;
+      font-family: 'Lucida Console', monospace;
+    }
+    .diffoscope table.diff tr:hover td {
+      background: #FFFF00;
+    }
+    .diffoscope .line {
+      color:#8080a0
+    }
+    .diffoscope th {
+      background: black;
+      color: white
+    }
+    .diffoscope .diffunmodified td {
+      background: #D0D0E0
+    }
+    .diffoscope .diffhunk td {
+      background: #A0A0A0
+    }
+    .diffoscope .diffadded td {
+      background: #CCFFCC
+    }
+    .diffoscope .diffdeleted td {
+      background: #FFCCCC
+    }
+    .diffoscope .diffchanged td {
+      background: #FFFFA0
+    }
+    .diffoscope ins, del {
+      background: #E0C880;
+      text-decoration: none
+    }
+    .diffoscope .diffponct {
+      color: #B08080
+    }
+    .diffoscope .comment {
+      font-style: italic;
+    }
+    .diffoscope .source {
+      font-weight: bold;
+    }
+    .diffoscope .error {
+      border: solid black 1px;
+      background: red;
+      color: white;
+      padding: 0.2em;
+    }
+    .diffoscope .anchor {
+      margin-left: 0.5em;
+      font-size: 80%;
+      color: #333;
+      text-decoration: none;
+      display: none;
+    }
+    .diffoscope .diffheader:hover .anchor {
+      display: inline;
+    }
+    .diffoscope table.diff tr.ondemand td {
+      background: #f99;
+      text-align: center;
+      padding: 0.5em 0;
+    }
+    .diffoscope table.diff tr.ondemand:hover td {
+      background: #faa;
+      cursor: pointer;
+    }
+    .diffoscope .diffcontrol {
+      float: left;
+      margin-right: 0.3em;
+      cursor: pointer;
+      display: none; /* currently, only available in html-dir output where jquery is enabled */
+    }
+    .diffoscope .diffcontrol-double {
+      line-height: 200%;
+    }
+    .diffoscope .colines {
+      width: 3em;
+    }
+    .diffoscope .coldiff {
+      width: 99%;
+    }
+  </style>
+  
+</head>
+<body class="diffoscope">
+
+<div class="difference">
+<div class="diffheader">
+<div class="diffcontrol diffcontrol-double">[−]</div>
+<div><span class="source">test1.tar</span> vs.</div>
+<div><span class="source">test2.tar</span>
+ <a class="anchor" href="#" name="">¶</a>
+</div>
+</div>
+<div class="difference">
+<div class="diffheader">
+<div class="diffcontrol">[−]</div>
+<div><span class="source">file list</span>
+ <a class="anchor" href="#file-list" name="file-list">¶</a>
+</div>
+</div>
+<table class="diff">
+<colgroup><col class="colines"/><col class="coldiff"/>
+<col class="colines"/><col class="coldiff"/></colgroup>
+
+<tr class="diffhunk"><td colspan="2">Offset 1, 4 lines modified</td>
+<td colspan="2">Offset 1, 4 lines modified</td></tr>
+
+<tr class="diffchanged">
+<td class="diffline">1 </td>
+<td class="diffpresent">
+drwxr-​xr-​x<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​0<span class="diffponct">·</span>​lunar<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​(1000)​<span class="diffponct">·</span>​lunar<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​ [...]
+</td>
+<td class="diffline">1 </td>
+<td class="diffpresent">
+drwxr-​xr-​x<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​0<span class="diffponct">·</span>​lunar<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​(1000)​<span class="diffponct">·</span>​lunar<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​ [...]
+</td>
+</tr>
+
+<tr class="diffchanged">
+<td class="diffline">2 </td>
+<td class="diffpresent">
+-​rw-​r-​-​r-​-​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​0<span class="diffponct">·</span>​lunar<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​(1000)​<span class="diffponct">·</span>​lunar<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</sp [...]
+</td>
+<td class="diffline">2 </td>
+<td class="diffpresent">
+-​rw-​r-​-​r-​-​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​0<span class="diffponct">·</span>​lunar<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​(1000)​<span class="diffponct">·</span>​lunar<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</sp [...]
+</td>
+</tr>
+
+<tr class="diffchanged">
+<td class="diffline">3 </td>
+<td class="diffpresent">
+crw-​r-​-​r-​-​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​0<span class="diffponct">·</span>​root<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​(0)​<span class="diffponct">·</span>​root<s [...]
+</td>
+<td class="diffline">3 </td>
+<td class="diffpresent">
+crw-​r-​-​r-​-​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​0<span class="diffponct">·</span>​root<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​(0)​<span class="diffponct">·</span>​root<s [...]
+</td>
+</tr>
+
+<tr class="diffchanged">
+<td class="diffline">4 </td>
+<td class="diffpresent">
+lrwxrwxrwx<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​0<span class="diffponct">·</span>​lunar<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​(1000)​<span class="diffponct">·</span>​lunar<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<s [...]
+</td>
+<td class="diffline">4 </td>
+<td class="diffpresent">
+lrwxrwxrwx<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​0<span class="diffponct">·</span>​lunar<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​(1000)​<span class="diffponct">·</span>​lunar<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<span class="diffponct">·</span>​<s [...]
+</td>
+</tr>
+
+</table>
+</div>
+<div class="difference">
+<div class="diffheader">
+<div class="diffcontrol">[−]</div>
+<div><span class="source">dir/text</span>
+ <a class="anchor" href="#dir-text" name="dir-text">¶</a>
+</div>
+</div>
+<table class="diff">
+<colgroup><col class="colines"/><col class="coldiff"/>
+<col class="colines"/><col class="coldiff"/></colgroup>
+
+<tr class="diffhunk"><td colspan="2">Offset 1, 6 lines modified</td>
+<td colspan="2">Offset 1, 12 lines modified</td></tr>
+
+<tr class="diffadded">
+<td colspan="2"> </td>
+<td class="diffline">1 </td>
+<td class="diffpresent">
+A<span class="diffponct">·</span>​common<span class="diffponct">·</span>​form<span class="diffponct">·</span>​of<span class="diffponct">·</span>​lorem<span class="diffponct">·</span>​ipsum<span class="diffponct">·</span>​reads:​
+</td>
+</tr>
+
+<tr class="diffadded">
+<td colspan="2"> </td>
+<td colspan="2"> </td>
+</tr>
+
+<tr class="diffunmodified">
+<td class="diffline">1 </td>
+<td class="diffpresent">
+Lorem<span class="diffponct">·</span>​ipsum<span class="diffponct">·</span>​dolor<span class="diffponct">·</span>​sit<span class="diffponct">·</span>​amet,​<span class="diffponct">·</span>​consectetur<span class="diffponct">·</span>​adipiscing<span class="diffponct">·</span>​elit,​<span class="diffponct">·</span>​sed<span class="diffponct">·</span>​do<span class="diffponct">·</span>​eiusmod<span class="diffponct">·</span>​tempor
+</td>
+<td class="diffline">2 </td>
+<td class="diffpresent">
+Lorem<span class="diffponct">·</span>​ipsum<span class="diffponct">·</span>​dolor<span class="diffponct">·</span>​sit<span class="diffponct">·</span>​amet,​<span class="diffponct">·</span>​consectetur<span class="diffponct">·</span>​adipiscing<span class="diffponct">·</span>​elit,​<span class="diffponct">·</span>​sed<span class="diffponct">·</span>​do<span class="diffponct">·</span>​eiusmod<span class="diffponct">·</span>​tempor
+</td>
+</tr>
+
+<tr class="diffunmodified">
+<td class="diffline">2 </td>
+<td class="diffpresent">
+incididunt<span class="diffponct">·</span>​ut<span class="diffponct">·</span>​labore<span class="diffponct">·</span>​et<span class="diffponct">·</span>​dolore<span class="diffponct">·</span>​magna<span class="diffponct">·</span>​aliqua.​<span class="diffponct">·</span>​Ut<span class="diffponct">·</span>​enim<span class="diffponct">·</span>​ad<span class="diffponct">·</span>​minim<span class="diffponct">·</span>​veniam,​<span class="diffponct">·</span>​quis
+</td>
+<td class="diffline">3 </td>
+<td class="diffpresent">
+incididunt<span class="diffponct">·</span>​ut<span class="diffponct">·</span>​labore<span class="diffponct">·</span>​et<span class="diffponct">·</span>​dolore<span class="diffponct">·</span>​magna<span class="diffponct">·</span>​aliqua.​<span class="diffponct">·</span>​Ut<span class="diffponct">·</span>​enim<span class="diffponct">·</span>​ad<span class="diffponct">·</span>​minim<span class="diffponct">·</span>​veniam,​<span class="diffponct">·</span>​quis
+</td>
+</tr>
+
+<tr class="diffunmodified">
+<td class="diffline">3 </td>
+<td class="diffpresent">
+nostrud<span class="diffponct">·</span>​exercitation<span class="diffponct">·</span>​ullamco<span class="diffponct">·</span>​laboris<span class="diffponct">·</span>​nisi<span class="diffponct">·</span>​ut<span class="diffponct">·</span>​aliquip<span class="diffponct">·</span>​ex<span class="diffponct">·</span>​ea<span class="diffponct">·</span>​commodo<span class="diffponct">·</span>​consequat.​
+</td>
+<td class="diffline">4 </td>
+<td class="diffpresent">
+nostrud<span class="diffponct">·</span>​exercitation<span class="diffponct">·</span>​ullamco<span class="diffponct">·</span>​laboris<span class="diffponct">·</span>​nisi<span class="diffponct">·</span>​ut<span class="diffponct">·</span>​aliquip<span class="diffponct">·</span>​ex<span class="diffponct">·</span>​ea<span class="diffponct">·</span>​commodo<span class="diffponct">·</span>​consequat.​
+</td>
+</tr>
+
+<tr class="diffunmodified">
+<td class="diffline">4 </td>
+<td class="diffpresent">
+Duis<span class="diffponct">·</span>​aute<span class="diffponct">·</span>​irure<span class="diffponct">·</span>​dolor<span class="diffponct">·</span>​in<span class="diffponct">·</span>​reprehenderit<span class="diffponct">·</span>​in<span class="diffponct">·</span>​voluptate<span class="diffponct">·</span>​velit<span class="diffponct">·</span>​esse<span class="diffponct">·</span>​cillum<span class="diffponct">·</span>​dolore<span class="diffponct">·</span>​eu
+</td>
+<td class="diffline">5 </td>
+<td class="diffpresent">
+Duis<span class="diffponct">·</span>​aute<span class="diffponct">·</span>​irure<span class="diffponct">·</span>​dolor<span class="diffponct">·</span>​in<span class="diffponct">·</span>​reprehenderit<span class="diffponct">·</span>​in<span class="diffponct">·</span>​voluptate<span class="diffponct">·</span>​velit<span class="diffponct">·</span>​esse<span class="diffponct">·</span>​cillum<span class="diffponct">·</span>​dolore<span class="diffponct">·</span>​eu
+</td>
+</tr>
+
+<tr class="diffunmodified">
+<td class="diffline">5 </td>
+<td class="diffpresent">
+fugiat<span class="diffponct">·</span>​nulla<span class="diffponct">·</span>​pariatur.​<span class="diffponct">·</span>​Excepteur<span class="diffponct">·</span>​sint<span class="diffponct">·</span>​occaecat<span class="diffponct">·</span>​cupidatat<span class="diffponct">·</span>​non<span class="diffponct">·</span>​proident,​<span class="diffponct">·</span>​sunt<span class="diffponct">·</span>​in
+</td>
+<td class="diffline">6 </td>
+<td class="diffpresent">
+fugiat<span class="diffponct">·</span>​nulla<span class="diffponct">·</span>​pariatur.​<span class="diffponct">·</span>​Excepteur<span class="diffponct">·</span>​sint<span class="diffponct">·</span>​occaecat<span class="diffponct">·</span>​cupidatat<span class="diffponct">·</span>​non<span class="diffponct">·</span>​proident,​<span class="diffponct">·</span>​sunt<span class="diffponct">·</span>​in
+</td>
+</tr>
+
+<tr class="diffunmodified">
+<td class="diffline">6 </td>
+<td class="diffpresent">
+culpa<span class="diffponct">·</span>​qui<span class="diffponct">·</span>​officia<span class="diffponct">·</span>​deserunt<span class="diffponct">·</span>​mollit<span class="diffponct">·</span>​anim<span class="diffponct">·</span>​id<span class="diffponct">·</span>​est<span class="diffponct">·</span>​laborum.​
+</td>
+<td class="diffline">7 </td>
+<td class="diffpresent">
+culpa<span class="diffponct">·</span>​qui<span class="diffponct">·</span>​officia<span class="diffponct">·</span>​deserunt<span class="diffponct">·</span>​mollit<span class="diffponct">·</span>​anim<span class="diffponct">·</span>​id<span class="diffponct">·</span>​est<span class="diffponct">·</span>​laborum.​
+</td>
+</tr>
+
+<tr class="diffadded">
+<td colspan="2"> </td>
+<td colspan="2"> </td>
+</tr>
+
+<tr class="diffadded">
+<td colspan="2"> </td>
+<td class="diffline">8 </td>
+<td class="diffpresent">
+"Lorem<span class="diffponct">·</span>​ipsum"<span class="diffponct">·</span>​text<span class="diffponct">·</span>​is<span class="diffponct">·</span>​derived<span class="diffponct">·</span>​from<span class="diffponct">·</span>​sections<span class="diffponct">·</span>​1.​10.​32-​-​3<span class="diffponct">·</span>​of<span class="diffponct">·</span>​Cicero&#x27;s<span class="diffponct">·</span>​De<span class="diffponct">·</span>​finibus
+</td>
+</tr>
+
+<tr class="diffadded">
+<td colspan="2"> </td>
+<td class="diffline">9 </td>
+<td class="diffpresent">
+bonorum<span class="diffponct">·</span>​et<span class="diffponct">·</span>​malorum<span class="diffponct">·</span>​(On<span class="diffponct">·</span>​the<span class="diffponct">·</span>​Ends<span class="diffponct">·</span>​of<span class="diffponct">·</span>​Goods<span class="diffponct">·</span>​and<span class="diffponct">·</span>​Evils,​<span class="diffponct">·</span>​or<span class="diffponct">·</span>​alternatively<span class="diffponct">·</span>​[About]
+</td>
+</tr>
+
+<tr class="diffadded">
+<td colspan="2"> </td>
+<td class="diffline">10 </td>
+<td class="diffpresent">
+The<span class="diffponct">·</span>​Purposes<span class="diffponct">·</span>​of<span class="diffponct">·</span>​Good<span class="diffponct">·</span>​and<span class="diffponct">·</span>​Evil)​.​
+</td>
+</tr>
+
+</table>
+</div>
+<div class="difference">
+<div class="diffheader">
+<div class="diffcontrol">[−]</div>
+<div><span class="source">dir/link</span>
+ <a class="anchor" href="#dir-link" name="dir-link">¶</a>
+</div>
+<div class="comment">symlink</div>
+</div>
+<table class="diff">
+<colgroup><col class="colines"/><col class="coldiff"/>
+<col class="colines"/><col class="coldiff"/></colgroup>
+
+<tr class="diffhunk"><td colspan="2">Offset 1, 1 lines modified</td>
+<td colspan="2">Offset 1, 1 lines modified</td></tr>
+
+<tr class="diffchanged">
+<td class="diffline">1 </td>
+<td class="diffpresent">
+destination:​<span class="diffponct">·</span>​broken
+</td>
+<td class="diffline">1 </td>
+<td class="diffpresent">
+destination:​<span class="diffponct">·</span>​<ins>really-​</ins>broken
+</td>
+</tr>
+
+</table>
+</div>
+</div>
+
+<div class="footer">Generated by <a href="https://diffoscope.org" rel="noopener noreferrer" target="_blank">diffoscope</a> 69</div>
+</body>
+</html>
+
diff --git a/tests/test_presenters.py b/tests/test_presenters.py
index 8d30756..888f614 100644
--- a/tests/test_presenters.py
+++ b/tests/test_presenters.py
@@ -18,10 +18,12 @@
 # along with diffoscope.  If not, see <https://www.gnu.org/licenses/>.
 
 import os
+import re
 import pytest
 
 from diffoscope.main import main
 
+re_html = re.compile(r'.*<body(?P<body>.*)<div class="footer">', re.MULTILINE | re.DOTALL)
 DATA_DIR = os.path.join(os.path.dirname(__file__), 'data')
 
 
@@ -46,6 +48,19 @@ def data(filename):
     with open(os.path.join(DATA_DIR, filename)) as f:
         return f.read()
 
+def extract_body(val):
+    """
+    Extract the salient parts of HTML fixtures that won't change between
+    versions, etc.
+    """
+
+    result = re_html.search(val).group('body')
+
+    # Ensure that we extracted something
+    assert len(result) > 0
+
+    return result
+
 def test_text_option_with_file(tmpdir, capsys):
     report_path = str(tmpdir.join('report.txt'))
 
@@ -83,7 +98,7 @@ def test_html_option_with_file(tmpdir, capsys):
 
     assert out == ''
     with open(report_path, 'r', encoding='utf-8') as f:
-        assert 'meta name="generator" content="diffoscope"' in f.read()
+        assert extract_body(f.read()) == extract_body(data('output.html'))
 
 def test_htmldir_option(tmpdir, capsys):
     html_dir = os.path.join(str(tmpdir), 'target')
@@ -93,9 +108,9 @@ def test_htmldir_option(tmpdir, capsys):
     assert out == ''
     assert os.path.isdir(html_dir)
     with open(os.path.join(html_dir, 'index.html'), 'r', encoding='utf-8') as f:
-        assert 'meta name="generator" content="diffoscope"' in f.read()
+        assert extract_body(f.read()) == extract_body(data('index.html'))
 
 def test_html_option_with_stdout(capsys):
     out = run(capsys, '--html', '-')
 
-    assert 'meta name="generator" content="diffoscope"' in out
+    assert extract_body(out) == extract_body(data('output.html'))

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git


More information about the diffoscope mailing list