Skip to content

Commit eb506bd

Browse files
committed
test(cli): cover output image export policy
Signed-off-by: Hassan Raza <raihassanraza10@gmail.com>
1 parent 5ddec27 commit eb506bd

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

docling/cli/main.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ def _split_list(raw: str | None) -> list[str] | None:
370370
return re.split(r"[;,]", raw)
371371

372372

373-
_IMAGE_CAPABLE_EXPORT_FORMATS = frozenset(
373+
_OUTPUT_FORMATS_SUPPORTING_IMAGE_EXPORT_MODE = frozenset(
374374
{
375375
OutputFormat.JSON,
376376
OutputFormat.YAML,
@@ -386,7 +386,8 @@ def _should_generate_export_images(
386386
to_formats: list[OutputFormat],
387387
) -> bool:
388388
return image_export_mode != ImageRefMode.PLACEHOLDER and any(
389-
to_format in _IMAGE_CAPABLE_EXPORT_FORMATS for to_format in to_formats
389+
to_format in _OUTPUT_FORMATS_SUPPORTING_IMAGE_EXPORT_MODE
390+
for to_format in to_formats
390391
)
391392

392393

tests/test_cli.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,24 @@ def test_should_generate_export_images(image_export_mode, to_formats, expected):
7474
assert _should_generate_export_images(image_export_mode, to_formats) is expected
7575

7676

77+
def test_image_export_policy_covers_all_output_formats():
78+
image_export_formats = {
79+
OutputFormat.JSON,
80+
OutputFormat.YAML,
81+
OutputFormat.HTML,
82+
OutputFormat.HTML_SPLIT_PAGE,
83+
OutputFormat.MARKDOWN,
84+
}
85+
non_image_export_formats = {
86+
OutputFormat.TEXT,
87+
OutputFormat.DOCTAGS,
88+
OutputFormat.VTT,
89+
}
90+
91+
assert image_export_formats.isdisjoint(non_image_export_formats)
92+
assert image_export_formats | non_image_export_formats == set(OutputFormat)
93+
94+
7795
@pytest.mark.parametrize(
7896
("to_format", "expect_generated_images"),
7997
[

0 commit comments

Comments
 (0)