Test accessing document annotations.
()
| 885 | |
| 886 | |
| 887 | def test_get_annotations(): |
| 888 | """Test accessing document annotations.""" |
| 889 | parser = DoclingPdfParser(loglevel="fatal") |
| 890 | |
| 891 | # Test with form_fields.pdf which has annotations |
| 892 | pdf_doc = parser.load( |
| 893 | path_or_stream="tests/data/regression/form_fields.pdf", lazy=True |
| 894 | ) |
| 895 | |
| 896 | annotations = pdf_doc.get_annotations() |
| 897 | |
| 898 | assert annotations is not None |
| 899 | assert annotations.form is not None or annotations.form is None |
| 900 | |
| 901 | # form_fields.pdf has form data |
| 902 | if annotations.form is not None: |
| 903 | assert isinstance(annotations.form, dict) |
| 904 | |
| 905 | # Test caching |
| 906 | annotations2 = pdf_doc.get_annotations() |
| 907 | assert annotations is annotations2 # Should return cached instance |
| 908 | |
| 909 | pdf_doc.unload() |
| 910 | |
| 911 | |
| 912 | def verify_annotations_recursive(true_annots, pred_annots): |
nothing calls this directly
no test coverage detected