Skip to content
This repository was archived by the owner on Apr 11, 2025. It is now read-only.

Commit e323cde

Browse files
Stony Wangbosd
authored andcommitted
Add test for __iter__ check
1 parent 61b0ae7 commit e323cde

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/test_common.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,3 +188,29 @@ def test_handler_with_pathlib(testdir):
188188
with open(filename, "rb") as f:
189189
handler = PDFHandler(f)
190190
assert handler._get_pages("1") == [1]
191+
192+
193+
def test_table_list_iter():
194+
def _make_table(page, order):
195+
t = Table([], [])
196+
t.page = page
197+
t.order = order
198+
return t
199+
200+
table_list = TableList(
201+
[_make_table(2, 1), _make_table(1, 1), _make_table(3, 4), _make_table(1, 2)]
202+
)
203+
# https://docs.python.org/3.12/library/functions.html#iter
204+
# https://docs.python.org/3.12/library/stdtypes.html#typeiter
205+
iterator_a = iter(table_list)
206+
assert iterator_a is not None
207+
item_a = next(iterator_a)
208+
assert item_a is not None
209+
210+
item_b = table_list.__getitem__(0)
211+
assert item_b is not None
212+
213+
iterator_b = table_list.__iter__()
214+
assert iterator_b is not None
215+
item_c = next(iterator_b)
216+
assert item_c is not None

0 commit comments

Comments
 (0)