MCPcopy Create free account
hub / github.com/pymupdf/PyMuPDF / test_707560

Function test_707560

tests/test_general.py:845–884  ·  view source on GitHub ↗

https://bugs.ghostscript.com/show_bug.cgi?id=707560 Ensure that redactions also remove characters with an empty width bbox.

()

Source from the content-addressed store, hash-verified

843
844
845def test_707560():
846 """https://bugs.ghostscript.com/show_bug.cgi?id=707560
847 Ensure that redactions also remove characters with an empty width bbox.
848 """
849 # Make text that will contain characters with an empty bbox.
850
851 greetings = (
852 "Hello, World!", # english
853 "Hallo, Welt!", # german
854 "سلام دنیا!", # persian
855 "வணக்கம், உலகம்!", # tamil
856 "สวัสดีชาวโลก!", # thai
857 "Привіт Світ!", # ucranian
858 "שלום עולם!", # hebrew
859 "ওহে বিশ্ব!", # bengali
860 "你好世界!", # chinese
861 "こんにちは世界!", # japanese
862 "안녕하세요, 월드!", # korean
863 "नमस्कार, विश्व !", # sanskrit
864 "हैलो वर्ल्ड!", # hindi
865 )
866 text = " ... ".join([g for g in greetings])
867 where = (50, 50, 400, 500)
868 story = pymupdf.Story(text)
869 bio = io.BytesIO()
870 writer = pymupdf.DocumentWriter(bio)
871 more = True
872 while more:
873 dev = writer.begin_page(pymupdf.paper_rect("a4"))
874 more, _ = story.place(where)
875 story.draw(dev)
876 writer.end_page()
877 writer.close()
878 doc = pymupdf.open("pdf", bio)
879 page = doc[0]
880 text = page.get_text()
881 assert text, "Unexpected: test page has no text."
882 page.add_redact_annot(page.rect)
883 page.apply_redactions()
884 assert not page.get_text(), "Unexpected: text not fully redacted."
885
886
887def test_3070():

Callers

nothing calls this directly

Calls 8

begin_pageMethod · 0.95
placeMethod · 0.95
drawMethod · 0.95
end_pageMethod · 0.95
closeMethod · 0.95
add_redact_annotMethod · 0.80
apply_redactionsMethod · 0.80
get_textMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…