MCPcopy Create free account
hub / github.com/bgeron/diff-pdf-visually / test_examples

Function test_examples

tests/test_examples.py:5–46  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3from pathlib import Path
4
5def test_examples():
6 ## Per page
7 assert [1] == pdfdiff_pages("tests/base.pdf", "tests/base_shifted_layout.pdf",
8 verbosity=0)
9 assert [-1] == pdfdiff_pages("tests/base.pdf", "tests/base_twice.pdf",
10 verbosity=0)
11 assert [2, 1] == pdfdiff_pages("tests/complex_1.pdf", "tests/complex_2.pdf",
12 verbosity=0, threshold=100)
13 assert [] == pdfdiff_pages("tests/complex_1.pdf", "tests/complex_2.pdf",
14 verbosity=0, threshold=10)
15 ## For the whole PDF
16 assert pdf_similar("tests/base.pdf", "tests/base_plus_white_text.pdf",
17 verbosity=0)
18 assert not pdf_similar("tests/base.pdf", "tests/base_shifted_layout.pdf",
19 verbosity=0)
20 assert not pdf_similar("tests/base.pdf", "tests/base_twice.pdf",
21 verbosity=0)
22 ## Deprecated function names
23 assert pdfdiff("tests/base.pdf", "tests/base_plus_white_text.pdf",
24 verbosity=0)
25 assert not pdfdiff("tests/base.pdf", "tests/base_shifted_layout.pdf",
26 verbosity=0)
27 assert not pdfdiff("tests/base.pdf", "tests/base_twice.pdf",
28 verbosity=0)
29
30 with TemporaryDirectory(dir=".", prefix="test_temp_") as d:
31 p = Path(d)
32
33 assert [2, 1] == pdfdiff_pages(
34 "tests/complex_1.pdf",
35 "tests/complex_2.pdf",
36 verbosity=0,
37 threshold=100,
38 tempdir=p,
39 )
40
41 for template in [
42 'a-{}.png', 'b-{}.png', 'diff-{}.png', 'log-{}.txt'
43 ]:
44 assert (p / template.format(1)).is_file()
45 assert (p / template.format(2)).is_file()
46 assert not (p / template.format(3)).exists()

Callers

nothing calls this directly

Calls 3

pdfdiff_pagesFunction · 0.90
pdf_similarFunction · 0.90
pdfdiffFunction · 0.90

Tested by

no test coverage detected