Confirm acceptance of supplied boxes list.
()
| 340 | |
| 341 | |
| 342 | def test_boxes_param(): |
| 343 | """Confirm acceptance of supplied boxes list.""" |
| 344 | filename = os.path.join(scriptdir, "resources", "small-table.pdf") |
| 345 | doc = pymupdf.open(filename) |
| 346 | page = doc[0] |
| 347 | paths = page.get_drawings() |
| 348 | box0 = page.cluster_drawings(drawings=paths)[0] |
| 349 | boxes = [box0] |
| 350 | words = page.get_text("words") |
| 351 | x_vals = [w[0] - 5 for w in words if w[4] in ("min", "max", "avg")] |
| 352 | for x in x_vals: |
| 353 | r = +box0 |
| 354 | r.x1 = x |
| 355 | boxes.append(r) |
| 356 | |
| 357 | y_vals = sorted(set([round(w[3]) for w in words])) |
| 358 | for y in y_vals[:-1]: # skip last one to avoid empty row |
| 359 | r = +box0 |
| 360 | r.y1 = y |
| 361 | boxes.append(r) |
| 362 | |
| 363 | tabs = page.find_tables(paths=[], add_boxes=boxes) |
| 364 | tab = tabs.tables[0] |
| 365 | assert tab.extract() == [ |
| 366 | ["Boiling Points °C", "min", "max", "avg"], |
| 367 | ["Noble gases", "-269", "-62", "-170.5"], |
| 368 | ["Nonmetals", "-253", "4827", "414.1"], |
| 369 | ["Metalloids", "335", "3900", "741.5"], |
| 370 | ["Metals", "357", ">5000", "2755.9"], |
| 371 | ] |
| 372 | |
| 373 | |
| 374 | def test_dotted_grid(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…