Skip to content

Commit b770f2d

Browse files
committed
Merge branch 'feat/degradations' into feat/generation-pipeline
# Conflicts: # src/ocrsmith/core/__init__.py # src/ocrsmith/core/app.py # src/ocrsmith/core/engine.py # tests/test_engine.py # tests/test_multiprocessing_dataset.py
2 parents de31426 + 7ed0727 commit b770f2d

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

tests/test_documents_layout.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -253,15 +253,27 @@ def test_no_text_is_lost_across_page_breaks(self, renderer, typography, rng, lat
253253
# Bullet markers and page furniture can add tokens; nothing may go missing.
254254
assert rendered_words >= expected
255255

256-
def test_two_columns_hold_more_per_page_than_one(self, renderer, typography, rng, latin_source):
256+
def test_columns_are_narrower_and_both_get_used(self, renderer, typography, rng, latin_source):
257+
# Not "two columns need fewer pages": narrower columns wrap more, and with orphan
258+
# control a two-column layout can legitimately need one page more. What the
259+
# feature actually guarantees is that blocks are confined to a column and that a
260+
# page with enough content uses both of them.
257261
content = ArticleTemplate(min_sections=5, max_sections=5).build(latin_source, rng)
258-
one = PageSpec.from_paper("a5", dpi=100, columns=1)
259-
two = PageSpec.from_paper("a5", dpi=100, columns=2)
262+
spec = PageSpec.from_paper("a5", dpi=100, columns=2)
260263

261-
single = renderer.render(content, one, typography, rng=random.Random(1), max_pages=40)
262-
double = renderer.render(content, two, typography, rng=random.Random(1), max_pages=40)
264+
pages = renderer.render(content, spec, typography, rng=random.Random(1), max_pages=40)
263265

264-
assert len(double) <= len(single)
266+
column_width = spec.column_width
267+
midpoint = spec.content_box.x0 + spec.content_box.width / 2
268+
used_left = used_right = False
269+
for page in pages:
270+
for region in page.page.regions:
271+
assert region.bbox.width <= column_width + 2
272+
if region.bbox.center[0] < midpoint:
273+
used_left = True
274+
else:
275+
used_right = True
276+
assert used_left and used_right
265277

266278
def test_right_to_left_documents_fill_the_right_column_first(
267279
self, renderer, typography, rng, arabic_source

0 commit comments

Comments
 (0)