Ensure that both annotations are fully created We do this by asserting equal top-used colors in respective pixmaps.
()
| 520 | assert rms == 0 |
| 521 | |
| 522 | def test_4254(): |
| 523 | """Ensure that both annotations are fully created |
| 524 | |
| 525 | We do this by asserting equal top-used colors in respective pixmaps. |
| 526 | """ |
| 527 | doc = pymupdf.open() |
| 528 | page = doc.new_page() |
| 529 | |
| 530 | rect = pymupdf.Rect(100, 100, 200, 150) |
| 531 | annot = page.add_freetext_annot(rect, "Test Annotation from minimal example") |
| 532 | annot.set_border(width=1, dashes=(3, 3)) |
| 533 | annot.set_opacity(0.5) |
| 534 | try: |
| 535 | annot.set_colors(stroke=(1, 0, 0)) |
| 536 | except ValueError as e: |
| 537 | assert 'cannot be used for FreeText annotations' in str(e), f'{e}' |
| 538 | else: |
| 539 | assert 0 |
| 540 | annot.update() |
| 541 | |
| 542 | rect = pymupdf.Rect(200, 200, 400, 400) |
| 543 | annot2 = page.add_freetext_annot(rect, "Test Annotation from minimal example pt 2") |
| 544 | annot2.set_border(width=1, dashes=(3, 3)) |
| 545 | annot2.set_opacity(0.5) |
| 546 | try: |
| 547 | annot2.set_colors(stroke=(1, 0, 0)) |
| 548 | except ValueError as e: |
| 549 | assert 'cannot be used for FreeText annotations' in str(e), f'{e}' |
| 550 | else: |
| 551 | assert 0 |
| 552 | annot.update() |
| 553 | annot2.update() |
| 554 | |
| 555 | # stores top color for each pixmap |
| 556 | top_colors = set() |
| 557 | for annot in page.annots(): |
| 558 | pix = annot.get_pixmap() |
| 559 | top_colors.add(pix.color_topusage()[1]) |
| 560 | |
| 561 | # only one color must exist |
| 562 | assert len(top_colors) == 1 |
| 563 | |
| 564 | def test_richtext(): |
| 565 | """Test creation of rich text FreeText annotations. |
nothing calls this directly
no test coverage detected
searching dependent graphs…