Mercurial > hgrepos > Python2 > PyMuPDF
view tests/test_word_delimiters.py @ 33:c4daa0c83d64
Apply also -fstack-clash-protection and -fstack-protector-strong for all generated binaries.
Only done if EXTRA_CHECKS is not empty and not 0.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Sun, 21 Sep 2025 17:55:13 +0200 |
| parents | 1d09e1dec1d9 |
| children |
line wrap: on
line source
import pymupdf import string def test_delimiters(): """Test changing word delimiting characters.""" doc = pymupdf.open() page = doc.new_page() text = "word1,word2 - word3. word4?word5." page.insert_text((50, 50), text) # Standard words extraction: # only spaces and line breaks start a new word words0 = [w[4] for w in page.get_text("words")] assert words0 == ["word1,word2", "-", "word3.", "word4?word5."] # extract words again words1 = [w[4] for w in page.get_text("words", delimiters=string.punctuation)] assert words0 != words1 assert " ".join(words1) == "word1 word2 word3 word4 word5" # confirm we will be getting old extraction assert [w[4] for w in page.get_text("words")] == words0
