tests/test_tables.py: make the two new table tests hold with layout and pymupdf4llm imported - #5144
Merged
Merged
Conversation
…nd pymupdf4llm imported test_table_header_is_computed_on_first_access() now uses the second table of chinese-tables.pdf. With layout, the caption above the first table is taken as an external header, which the test is not about; the second table has its header as its top row with or without layout. test_find_tables_refine_splits_a_repeated_leading_header() now writes "2024/01" instead of "2024-01". pymupdf4llm sets unset_quad_corrections(True) on import, and then "-" and "." are extracted as a line of their own. The row-count assertion prints the extracted tables if it fails. This replaces the layout-dependent expectations added in 010f012, so both tests check the same result with or without layout and pymupdf4llm.
veget-able
force-pushed
the
table-tests-layout-default
branch
from
September 28, 2026 16:07
1a9de78 to
fe40317
Compare
julian-smith-artifex-com
approved these changes
Sep 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two tests added in #5136 assumed that neither layout nor pymupdf4llm is imported. With the 2.0 setup, where
import pymupdfalso imports both, they fail. This PR changes the tests only; the table code is unchanged.main now has layout-dependent expectations for these two tests (010f012, "Cope with regression"). This PR replaces them, so both tests check the same result with or without layout and pymupdf4llm, instead of expecting the caption as header or the split hyphens under layout.
test_table_header_is_computed_on_first_access()
With layout, the caption above the first table of
chinese-tables.pdfis taken as an external header. This already happens with 1.28.2 and is not what the test checks. The test is aboutTable.headerbeing computed lazily and only once, so it now uses the second table, whose header is its top row with or without layout.test_find_tables_refine_splits_a_repeated_leading_header()
pymupdf4llm calls
TOOLS.unset_quad_corrections(True)on import. After that, small glyphs such as "-" and "." are extracted as a line of their own, so "2024-01" comes back as "2024 01\n-". The synthetic dates now use "2024/01", which extracts the same either way. The row-count assertion also prints the extracted tables when it fails, to make any remaining difference visible.Checked with
Both tests pass in all of these combinations. Rebased on current main, all 46 tests in
tests/test_tables.pypass with the 2.0 defaults and withPYMUPDF_TEST_USE_LAYOUT=0 PYMUPDF_TEST_USE_4LLM=0.