Compare pickled tables with those of the current run.
()
| 13 | |
| 14 | |
| 15 | def test_table1(): |
| 16 | """Compare pickled tables with those of the current run.""" |
| 17 | pickle_in = open(pickle_file, "rb") |
| 18 | doc = pymupdf.open(filename) |
| 19 | page = doc[0] |
| 20 | tabs = page.find_tables() |
| 21 | cells = tabs[0].cells + tabs[1].cells # all table cell tuples on page |
| 22 | extracts = [tabs[0].extract(), tabs[1].extract()] # all table cell content |
| 23 | old_data = pickle.load(pickle_in) # previously saved data |
| 24 | |
| 25 | # Compare cell contents |
| 26 | assert old_data["extracts"] == extracts # same cell contents |
| 27 | |
| 28 | # Compare cell coordinates. |
| 29 | # Cell rectangles may get somewhat larger due to more cautious border |
| 30 | # computations, but any differences must be small. |
| 31 | old_cells = old_data["cells"][0] + old_data["cells"][1] |
| 32 | assert len(cells) == len(old_cells) |
| 33 | for i in range(len(cells)): |
| 34 | c1 = pymupdf.Rect(cells[i]) # new cell coordinates |
| 35 | c0 = pymupdf.Rect(old_cells[i]) # old cell coordinates |
| 36 | assert c0 in c1 # always: old contained in new |
| 37 | assert abs(c1 - c0) < 0.2 # difference must be small |
| 38 | |
| 39 | |
| 40 | def test_table2(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…