Commit 25f11b68 authored by Jérémy Bobbio's avatar Jérémy Bobbio

Add tests for PDF comparator

parent 41f8402a
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# debbindiff: highlight differences between two builds of Debian packages
#
# Copyright © 2015 Jérémy Bobbio <lunar@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
@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
@@ -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
@@ -1,3 +1,3 @@
-Hello World!
+Hello Sick Sad World!
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment