Package: src:fpdf2
Version: 2.8.9-1
Severity: serious
Tags: sid forky
autopkg test failure seen with pillow 13.0.0:
[...]
=================================== FAILURES
===================================
269s _____________________ test_image_with_explicit_dimensions
______________________
269s
269s tmp_path =
PosixPath('/tmp/pytest-of-test/pytest-0/test_image_with_explicit_dimen0')
269s
269s def test_image_with_explicit_dimensions(tmp_path):
269s pdf = FPDF()
269s pdf.set_margin(0)
269s pdf.add_page()
269s pdf.image(
269s HERE / "png_images/6c853ed9dacd5716bc54eb59cec30889.png",
269s w=pdf.epw,
269s dims=(500, 500),
269s )
269s > assert_pdf_equal(pdf, HERE /
"image_with_explicit_dimensions.pdf", tmp_path)
269s
269s test/image/test_full_page_image.py:54:
269s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _
269s
269s actual = <fpdf.fpdf.FPDF object at 0x7f55b2f8a900>
269s expected =
PosixPath('/tmp/autopkgtest.OAzmCQ/build.cKt/src/test/image/image_with_explicit_dimensions.pdf')
269s tmp_path =
PosixPath('/tmp/pytest-of-test/pytest-0/test_image_with_explicit_dimen0')
269s linearize = False, at_epoch = True, generate = False,
ignore_id_changes = False
269s ignore_original_obj_ids = False, ignore_xref_offsets = False
269s
269s def assert_pdf_equal(
269s actual,
269s expected,
269s tmp_path,
269s linearize=False,
269s at_epoch=True,
269s generate=False,
269s ignore_id_changes=False,
269s ignore_original_obj_ids=False,
269s ignore_xref_offsets=False,
269s ):
269s """
269s This compare the output of a `FPDF` instance (or `Template`
instance),
269s with the provided PDF file.
269s
269s The `CreationDate` of the newly generated PDF is fixed, so
that it never triggers
269s a diff.
269s
269s If the `qpdf` command is available on the `$PATH`, it will
be used to perform the
269s comparison, as it greatly helps debugging diffs. Otherwise,
a hash-based comparison
269s logic is used as a fallback.
269s
269s Args:
269s actual: instance of `FPDF` or `Template`. The `output`
or `render` method
269s will be called on it.
269s expected: instance of `FPDF`, `bytearray` or file path
to a PDF file
269s matching the expected output
269s tmp_path (Path): temporary directory provided by pytest
individually to the
269s caller test function
269s generate (bool): only generate `pdf` output to
`rel_expected_pdf_filepath`
269s and return. Useful to create new tests.
269s """
269s if isinstance(actual, Template):
269s actual.render()
269s actual_pdf = actual.pdf
269s else:
269s actual_pdf = actual
269s if at_epoch:
269s actual_pdf.creation_date = EPOCH
269s if generate:
269s assert isinstance(expected, pathlib.Path), (
269s "When passing `True` to `generate`"
269s "a pathlib.Path must be provided as the `expected`
parameter"
269s )
269s actual_pdf.output(expected.open("wb"), linearize=linearize)
269s return
269s # Force ignore_id_changes when Python is linked against
zlib-ng,
269s # as the compressed data is not 100% identical to standard
zlib.
269s # https://github.com/python/cpython/pull/131438
269s if USING_ZLIB_NG and QPDF_AVAILABLE:
269s ignore_id_changes = True
269s if isinstance(expected, pathlib.Path):
269s expected_pdf_path = expected
269s else:
269s expected_pdf_path = tmp_path / "expected.pdf"
269s with expected_pdf_path.open("wb") as pdf_file:
269s if isinstance(expected, (bytes, bytearray)):
269s pdf_file.write(expected)
269s else:
269s expected.set_creation_date(EPOCH)
269s expected.output(pdf_file, linearize=linearize)
269s actual_pdf_path = tmp_path / "actual.pdf"
269s with actual_pdf_path.open("wb") as pdf_file:
269s actual_pdf.output(pdf_file, linearize=linearize)
269s if QPDF_AVAILABLE: # Favor qpdf-based comparison, as it
helps a lot debugging:
269s actual_qpdf = _qpdf(actual_pdf_path)
269s expected_qpdf = _qpdf(expected_pdf_path)
269s (tmp_path / "actual_qpdf.pdf").write_bytes(actual_qpdf)
269s (tmp_path / "expected_qpdf.pdf").write_bytes(expected_qpdf)
269s actual_lines = actual_qpdf.splitlines()
269s expected_lines = expected_qpdf.splitlines()
269s if ignore_id_changes:
269s actual_lines = filter_out_doc_id(actual_lines)
269s expected_lines = filter_out_doc_id(expected_lines)
269s if ignore_original_obj_ids:
269s actual_lines =
filter_out_original_obj_ids(actual_lines)
269s expected_lines =
filter_out_original_obj_ids(expected_lines)
269s if ignore_xref_offsets:
269s actual_lines = filter_out_xref_offsets(actual_lines)
269s expected_lines =
filter_out_xref_offsets(expected_lines)
269s if actual_lines != expected_lines:
269s # It is important to reduce the size of both list
of bytes here,
269s # to avoid .assertSequenceEqual to take forever to
finish, that itself calls difflib.ndiff,
269s # that has cubic complexity from this comment by
Tim Peters: https://bugs.python.org/issue6931#msg223459
269s actual_lines = subst_streams_with_hashes(actual_lines)
269s expected_lines =
subst_streams_with_hashes(expected_lines)
269s > assert actual_lines == expected_lines
269s E assert [b'%PDF-1.3',...1 0 obj', ...] ==
[b'%PDF-1.3',...1 0 obj', ...]
269s E
269s E At index 99 diff:
b"\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2}\xc0\xa2~\xc0\xa2~\xc0\xa2}\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2}\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa2~\xc0\xa...
269s E
269s E ...Full output truncated (93558 lines hidden), use
'-vv' to show
269s
269s test/conftest.py:172: AssertionError