[Reproducible-commits] [debbindiff] 01/06: Add tests for PDF comparator

Jérémy Bobbio lunar at moszumanska.debian.org
Wed Jun 24 12:45:53 UTC 2015


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

lunar pushed a commit to branch master
in repository debbindiff.

commit 25f11b68c07ca61cc0661664b9e41a4266503ecd
Author: Jérémy Bobbio <lunar at debian.org>
Date:   Wed Jun 24 12:09:35 2015 +0000

    Add tests for PDF comparator
---
 tests/comparators/test_pdf.py         | 43 ++++++++++++++++++++++
 tests/data/pdf_internal_expected_diff | 52 ++++++++++++++++++++++++++
 tests/data/pdf_text_expected_diff     |  5 +++
 tests/data/test1.pdf                  | 69 +++++++++++++++++++++++++++++++++++
 tests/data/test2.pdf                  | 69 +++++++++++++++++++++++++++++++++++
 5 files changed, 238 insertions(+)

diff --git a/tests/comparators/test_pdf.py b/tests/comparators/test_pdf.py
new file mode 100644
index 0000000..2f5d659
--- /dev/null
+++ b/tests/comparators/test_pdf.py
@@ -0,0 +1,43 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# debbindiff: highlight differences between two builds of Debian packages
+#
+# Copyright © 2015 Jérémy Bobbio <lunar at debian.org>
+#
+# debbindiff is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# debbindiff is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with debbindiff.  If not, see <http://www.gnu.org/licenses/>.
+
+import os.path
+import shutil
+import pytest
+from debbindiff.comparators.pdf import compare_pdf_files
+
+TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.pdf') 
+TEST_FILE2_PATH = os.path.join(os.path.dirname(__file__), '../data/test2.pdf') 
+
+def test_no_differences():
+    differences = compare_pdf_files(TEST_FILE1_PATH, TEST_FILE1_PATH)
+    assert len(differences) == 0
+
+ at pytest.fixture
+def differences():
+    return compare_pdf_files(TEST_FILE1_PATH, TEST_FILE2_PATH)[0].details # skip container with path
+
+def test_text_diff(differences):
+    expected_diff = open(os.path.join(os.path.dirname(__file__), '../data/pdf_text_expected_diff')).read()
+    assert differences[0].unified_diff == expected_diff
+
+def test_internal_diff(differences):
+    expected_diff = open(os.path.join(os.path.dirname(__file__), '../data/pdf_internal_expected_diff')).read()
+    assert differences[1].unified_diff == expected_diff
diff --git a/tests/data/pdf_internal_expected_diff b/tests/data/pdf_internal_expected_diff
new file mode 100644
index 0000000..de5669f
--- /dev/null
+++ b/tests/data/pdf_internal_expected_diff
@@ -0,0 +1,52 @@
+@@ -11,23 +11,23 @@
+ /Kids [3 0 R]
+ /Type /Pages
+ /Count 1
+ >>
+ endobj 
+ 4 0 obj 
+ <<
+-/Length 85
++/Length 109
+ >>
+ stream
+ q
+ 
+ BT
+ 36.0 747.384 Td
+ /F1.0 12 Tf
+-[<48656c6c6f2057> 30 <6f72> -15 <6c6421>] TJ
++[<48656c6c6f20536963> 20 <6b205361642057> 30 <6f72> -15 <6c6421>] TJ
+ ET
+ 
+ Q
+ 
+ endstream 
+ endobj 
+ 3 0 obj 
+@@ -61,21 +61,21 @@
+ /Producer <feff0050007200610077006e>
+ >>
+ endobj xref
+ 0 7
+ 0000000000 65535 f 
+ 0000000015 00000 n 
+ 0000000066 00000 n 
+-0000000263 00000 n 
++0000000288 00000 n 
+ 0000000125 00000 n 
+-0000000462 00000 n 
+-0000000561 00000 n 
++0000000487 00000 n 
++0000000586 00000 n 
+ trailer
+ 
+ <<
+ /Info 6 0 R
+ /Root 1 0 R
+ /Size 7
+ >>
+ startxref
+-656
++681
+ %%EOF
diff --git a/tests/data/pdf_text_expected_diff b/tests/data/pdf_text_expected_diff
new file mode 100644
index 0000000..ca88824
--- /dev/null
+++ b/tests/data/pdf_text_expected_diff
@@ -0,0 +1,5 @@
+@@ -1,3 +1,3 @@
+-Hello World!
++Hello Sick Sad World!
+ 
+ 

diff --git a/tests/data/test1.pdf b/tests/data/test1.pdf
new file mode 100644
index 0000000..1a08cb6
--- /dev/null
+++ b/tests/data/test1.pdf
@@ -0,0 +1,69 @@
+%PDF-1.3
+%����
+1 0 obj
+<< /Creator <feff0050007200610077006e>
+/Producer <feff0050007200610077006e>
+>>
+endobj
+2 0 obj
+<< /Type /Catalog
+/Pages 3 0 R
+>>
+endobj
+3 0 obj
+<< /Type /Pages
+/Count 1
+/Kids [5 0 R]
+>>
+endobj
+4 0 obj
+<< /Length 85
+>>
+stream
+q
+
+BT
+36.0 747.384 Td
+/F1.0 12 Tf
+[<48656c6c6f2057> 30 <6f72> -15 <6c6421>] TJ
+ET
+
+Q
+
+endstream
+endobj
+5 0 obj
+<< /Type /Page
+/Parent 3 0 R
+/MediaBox [0 0 612.0 792.0]
+/Contents 4 0 R
+/Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
+/Font << /F1.0 6 0 R
+>>
+>>
+>>
+endobj
+6 0 obj
+<< /Type /Font
+/Subtype /Type1
+/BaseFont /Helvetica
+/Encoding /WinAnsiEncoding
+>>
+endobj
+xref
+0 7
+0000000000 65535 f 
+0000000015 00000 n 
+0000000109 00000 n 
+0000000158 00000 n 
+0000000215 00000 n 
+0000000350 00000 n 
+0000000528 00000 n 
+trailer
+<< /Size 7
+/Root 2 0 R
+/Info 1 0 R
+>>
+startxref
+625
+%%EOF
diff --git a/tests/data/test2.pdf b/tests/data/test2.pdf
new file mode 100644
index 0000000..f504524
--- /dev/null
+++ b/tests/data/test2.pdf
@@ -0,0 +1,69 @@
+%PDF-1.3
+%����
+1 0 obj
+<< /Creator <feff0050007200610077006e>
+/Producer <feff0050007200610077006e>
+>>
+endobj
+2 0 obj
+<< /Type /Catalog
+/Pages 3 0 R
+>>
+endobj
+3 0 obj
+<< /Type /Pages
+/Count 1
+/Kids [5 0 R]
+>>
+endobj
+4 0 obj
+<< /Length 109
+>>
+stream
+q
+
+BT
+36.0 747.384 Td
+/F1.0 12 Tf
+[<48656c6c6f20536963> 20 <6b205361642057> 30 <6f72> -15 <6c6421>] TJ
+ET
+
+Q
+
+endstream
+endobj
+5 0 obj
+<< /Type /Page
+/Parent 3 0 R
+/MediaBox [0 0 612.0 792.0]
+/Contents 4 0 R
+/Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
+/Font << /F1.0 6 0 R
+>>
+>>
+>>
+endobj
+6 0 obj
+<< /Type /Font
+/Subtype /Type1
+/BaseFont /Helvetica
+/Encoding /WinAnsiEncoding
+>>
+endobj
+xref
+0 7
+0000000000 65535 f 
+0000000015 00000 n 
+0000000109 00000 n 
+0000000158 00000 n 
+0000000215 00000 n 
+0000000375 00000 n 
+0000000553 00000 n 
+trailer
+<< /Size 7
+/Root 2 0 R
+/Info 1 0 R
+>>
+startxref
+650
+%%EOF

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



More information about the Reproducible-commits mailing list