add a regression test pinning down extract_items precedence: when a PictureItem has both an inline image.uri AND a fallback in existing_picture_data, the live URI wins.

This commit is contained in:
Yiorgis Gozadinos 2026-04-30 15:35:13 +03:00
parent 875c635a77
commit 35e6568f59
No known key found for this signature in database

View file

@ -470,6 +470,17 @@ class TestExtractItemsPictureBytes:
picture_items = [i for i in items if i.label == "picture"] picture_items = [i for i in items if i.label == "picture"]
assert picture_items[0].picture_data == b"snapshot-picture-bytes" assert picture_items[0].picture_data == b"snapshot-picture-bytes"
def test_live_image_uri_wins_over_existing_picture_data(self):
"""When both an inline URI and a snapshot are available, the URI wins."""
doc = _docling_doc_with_picture()
snapshot = {"#/pictures/0": b"snapshot-bytes-should-not-be-used"}
items = extract_items("doc-1", doc, existing_picture_data=snapshot)
picture_items = [i for i in items if i.label == "picture"]
data = picture_items[0].picture_data
assert data is not None
assert data.startswith(b"\x89PNG")
assert data != b"snapshot-bytes-should-not-be-used"
class TestExtractItemTextDescription: class TestExtractItemTextDescription:
"""A2b: extract_item_text returns VLM description text for PictureItems.""" """A2b: extract_item_text returns VLM description text for PictureItems."""