Beispiel #1
0
 def test_filters_results_with_multiple_callbacks(self, table) -> None:
     callbacks = [lambda box:  "4" in box.get_text(), lambda box: box.x1 < 250]
     result = list(select_textboxes(table, *callbacks))
     assert len(result) == 2
Beispiel #2
0
 def test_returns_empty_list_when_no_matches_with_callback(self, table) -> None:
     callbacks = [lambda box:  "Z" in box.get_text()]
     result = list(select_textboxes(table, *callbacks))
     assert len(result) == 0
Beispiel #3
0
 def test_filters_results_with_callback_function(self, table) -> None:
     result = list(select_textboxes(table, lambda box:  "4" in box.get_text()))
     assert len(result) == 4
Beispiel #4
0
 def test_returns_textboxes_from_multiple_pages(self, paragraphs) -> None:
     result = select_textboxes(paragraphs)
     for textbox in result:
         assert isinstance(textbox, LTTextBox)
Beispiel #5
0
 def test_returns_textboxes_from_single_page(self, pages) -> None:
     result = select_textboxes(pages[0])
     for textbox in result:
         assert isinstance(textbox, LTTextBox)
Beispiel #6
0
 def test_returns_iterable(self, text) -> None:
     result = select_textboxes(text)
     assert isinstance(result, Iterable)
Beispiel #7
0
 def textboxes(self, paragraphs):
     return list(select_textboxes(paragraphs))