Skip to content

Commit

Permalink
add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
magdaaniol committed Dec 23, 2024
1 parent 8562ccf commit 42fa2f2
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/test_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,22 @@ def test_general(path, nlp, span_labels):
assert span.label_ in span_labels
assert isinstance(span._.get(layout.attrs.span_layout), SpanLayout)

@pytest.mark.parametrize("path, pg_no", [(PDF_STARCRAFT, 6), (PDF_SIMPLE, 1)])
def test_pages(path, pg_no, nlp):
layout = spaCyLayout(nlp)
doc = layout(path)
# This should not raise a KeyError when accessing `pages` dict
# Key Error would mean a mismatched pagination on document layout and span layout
result = layout.get_pages(doc)
assert len(result) == pg_no
assert result[0][0].page_no == 1
if pg_no == 6:
# there should be 18 spans on the pg_no 1
assert len(result[0][1]) == 18
elif pg_no == 1:
# there should be 4 spans on pg_no 1
assert len(result[0][1]) == 4


@pytest.mark.parametrize("path", [PDF_SIMPLE, DOCX_SIMPLE])
@pytest.mark.parametrize("separator", ["\n\n", ""])
Expand Down

0 comments on commit 42fa2f2

Please sign in to comment.