[Git][reproducible-builds/diffoscope][master] Update .epub test data methodology after improving XML file parsing.

Chris Lamb (@lamby) gitlab at salsa.debian.org
Fri Nov 12 15:46:49 UTC 2021



Chris Lamb pushed to branch master at Reproducible Builds / diffoscope


Commits:
647eb03f by Chris Lamb at 2021-11-12T07:46:37-08:00
Update .epub test data methodology after improving XML file parsing.

- - - - -


2 changed files:

- tests/comparators/test_epub.py
- tests/data/epub_expected_diffs


Changes:

=====================================
tests/comparators/test_epub.py
=====================================
@@ -55,8 +55,18 @@ def test_differences(differences):
     assert differences[2].source2 == "toc.ncx"
     assert differences[3].source1 == "ch001.xhtml"
     assert differences[3].source2 == "ch001.xhtml"
-    expected_diff = get_data("epub_expected_diffs")
-    assert expected_diff == "".join(map(lambda x: x.unified_diff, differences))
+
+    # Flatten everything recursively, as XMLFile will contain reformatted data
+    # under Difference.details.
+    def fn(difference):
+        if difference.unified_diff:
+            yield difference.unified_diff
+        for x in difference.details:
+            yield from fn(x)
+
+    val = "\n".join("\n".join(fn(x)) for x in differences)
+
+    assert val == get_data("epub_expected_diffs")
 
 
 @skip_unless_tools_exist("zipinfo")


=====================================
tests/data/epub_expected_diffs
=====================================
@@ -21,9 +21,10 @@
 +-rw----     0.0 fat      655 b- defX 15-Oct-27 11:33 nav.xhtml
 +-rw----     0.0 fat      615 b- defX 15-Oct-27 11:33 ch001.xhtml
 +9 files, 4535 bytes uncompressed, 2325 bytes compressed:  48.7%
+
 @@ -1,13 +1,13 @@
- <?xml version="1.0" encoding="UTF-8"?>
- <package version="2.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="epub-id-1">
+ <?xml version="1.0" encoding="utf-8"?>
+ <package xmlns="http://www.idpf.org/2007/opf" version="2.0" unique-identifier="epub-id-1">
    <metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
 -    <dc:identifier id="epub-id-1">urn:uuid:488fe0b5-29d9-4d64-a023-ca08947d78ae</dc:identifier>
 +    <dc:identifier id="epub-id-1">urn:uuid:c3082605-195c-4273-acad-528beceba843</dc:identifier>
@@ -33,34 +34,35 @@
      <dc:language>en-US</dc:language>
    </metadata>
    <manifest>
-     <item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml" />
-     <item id="style" href="stylesheet.css" media-type="text/css" />
-     <item id="nav" href="nav.xhtml" media-type="application/xhtml+xml" />
-     <item id="title_page_xhtml" href="title_page.xhtml" media-type="application/xhtml+xml" />
+     <item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml"/>
+     <item id="style" href="stylesheet.css" media-type="text/css"/>
+     <item id="nav" href="nav.xhtml" media-type="application/xhtml+xml"/>
+     <item id="title_page_xhtml" href="title_page.xhtml" media-type="application/xhtml+xml"/>
+
 @@ -1,11 +1,11 @@
- <?xml version="1.0" encoding="UTF-8"?>
- <ncx version="2005-1" xmlns="http://www.daisy.org/z3986/2005/ncx/">
+ <?xml version="1.0" encoding="utf-8"?>
+ <ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1">
    <head>
--    <meta name="dtb:uid" content="urn:uuid:488fe0b5-29d9-4d64-a023-ca08947d78ae" />
-+    <meta name="dtb:uid" content="urn:uuid:c3082605-195c-4273-acad-528beceba843" />
-     <meta name="dtb:depth" content="1" />
-     <meta name="dtb:totalPageCount" content="0" />
-     <meta name="dtb:maxPageNumber" content="0" />
+-    <meta name="dtb:uid" content="urn:uuid:488fe0b5-29d9-4d64-a023-ca08947d78ae"/>
++    <meta name="dtb:uid" content="urn:uuid:c3082605-195c-4273-acad-528beceba843"/>
+     <meta name="dtb:depth" content="1"/>
+     <meta name="dtb:totalPageCount" content="0"/>
+     <meta name="dtb:maxPageNumber" content="0"/>
    </head>
    <docTitle>
      <text>Test Ebook</text>
    </docTitle>
-@@ -8,12 +8,12 @@
-   <title>Test Ebook</title>
-   <link rel="stylesheet" type="text/css" href="stylesheet.css" />
- </head>
- <body>
- <div id="test-ebook" class="section level1 unnumbered">
- <h1>Test Ebook</h1>
- <p>Hello World!</p>
--<p>Time: 12:32</p>
-+<p>Time: 12:33</p>
- </div>
- </body>
+
+@@ -10,11 +10,11 @@
+     <title>Test Ebook</title>
+     <link rel="stylesheet" type="text/css" href="stylesheet.css"/>
+   </head>
+   <body>
+     <div id="test-ebook" class="section level1 unnumbered">
+       <h1>Test Ebook</h1>
+       <p>Hello World!</p>
+-      <p>Time: 12:32</p>
++      <p>Time: 12:33</p>
+     </div>
+   </body>
  </html>
- 



View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/commit/647eb03f40531427eb8f728c069d27b4495c5121

-- 
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/commit/647eb03f40531427eb8f728c069d27b4495c5121
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.reproducible-builds.org/pipermail/rb-commits/attachments/20211112/31d63dd0/attachment.htm>


More information about the rb-commits mailing list