@@ -21,7 +21,7 @@ class TestHTMLParagraph(unittest.TestCase):
|
||||
self.assertEqual(len(paragraphs), 1)
|
||||
self.assertEqual(len(paragraphs[0]), 4)
|
||||
|
||||
for w1, t1 in zip(paragraphs[0].words(), "This is a paragraph.".split(" ")):
|
||||
for w1, t1 in zip(paragraphs[0].words_iter(), "This is a paragraph.".split(" ")):
|
||||
self.assertEqual(w1[1].text, t1)
|
||||
|
||||
def test_multiple(self):
|
||||
@@ -31,10 +31,10 @@ class TestHTMLParagraph(unittest.TestCase):
|
||||
self.assertEqual(len(paragraphs[0]), 4)
|
||||
self.assertEqual(len(paragraphs[1]), 4)
|
||||
|
||||
for w1, t1 in zip(paragraphs[0].words(), "This is a paragraph.".split(" ")):
|
||||
for w1, t1 in zip(paragraphs[0].words_iter(), "This is a paragraph.".split(" ")):
|
||||
self.assertEqual(w1[1].text, t1)
|
||||
|
||||
for w1, t1 in zip(paragraphs[1].words(), "This is another paragraph.".split(" ")):
|
||||
for w1, t1 in zip(paragraphs[1].words_iter(), "This is another paragraph.".split(" ")):
|
||||
self.assertEqual(w1[1].text, t1)
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ class TestHTMLStyledParagraphs(unittest.TestCase):
|
||||
self.assertEqual(len(blocks), 1)
|
||||
self.assertIsInstance(blocks[0], Paragraph)
|
||||
|
||||
words = list(blocks[0].words())
|
||||
words = list(blocks[0].words_iter())
|
||||
self.assertEqual(len(words), 7) # "This is bold text in a paragraph."
|
||||
|
||||
# Check that 'bold' and 'text' words have bold font weight
|
||||
@@ -71,7 +71,7 @@ class TestHTMLStyledParagraphs(unittest.TestCase):
|
||||
self.assertEqual(len(blocks), 1)
|
||||
self.assertIsInstance(blocks[0], Paragraph)
|
||||
|
||||
words = list(blocks[0].words())
|
||||
words = list(blocks[0].words_iter())
|
||||
|
||||
# Check that 'italic' and 'text' words have italic font style
|
||||
italic_word = words[2][1] # 'italic'
|
||||
@@ -87,7 +87,7 @@ class TestHTMLStyledParagraphs(unittest.TestCase):
|
||||
blocks = parse_html_string(text)
|
||||
self.assertEqual(len(blocks), 1)
|
||||
|
||||
words = list(blocks[0].words())
|
||||
words = list(blocks[0].words_iter())
|
||||
underlined_word = words[2][1] # 'underlined'
|
||||
self.assertEqual(underlined_word.style.decoration, TextDecoration.UNDERLINE)
|
||||
|
||||
@@ -97,7 +97,7 @@ class TestHTMLStyledParagraphs(unittest.TestCase):
|
||||
blocks = parse_html_string(text)
|
||||
self.assertEqual(len(blocks), 1)
|
||||
|
||||
words = list(blocks[0].words())
|
||||
words = list(blocks[0].words_iter())
|
||||
strike_word = words[2][1] # 'strikethrough'
|
||||
self.assertEqual(strike_word.style.decoration, TextDecoration.STRIKETHROUGH)
|
||||
|
||||
@@ -108,7 +108,7 @@ class TestHTMLStyledParagraphs(unittest.TestCase):
|
||||
self.assertEqual(len(blocks), 1)
|
||||
self.assertIsInstance(blocks[0], Paragraph)
|
||||
|
||||
words = list(blocks[0].words())
|
||||
words = list(blocks[0].words_iter())
|
||||
|
||||
# Find the styled words
|
||||
styled_words = []
|
||||
@@ -130,7 +130,7 @@ class TestHTMLStyledParagraphs(unittest.TestCase):
|
||||
self.assertEqual(len(blocks), 1)
|
||||
self.assertIsInstance(blocks[0], Paragraph)
|
||||
|
||||
words = list(blocks[0].words())
|
||||
words = list(blocks[0].words_iter())
|
||||
|
||||
# Check for bold word
|
||||
bold_words = [w for _, w in words if w.style.weight == FontWeight.BOLD]
|
||||
@@ -150,7 +150,7 @@ class TestHTMLStyledParagraphs(unittest.TestCase):
|
||||
blocks = parse_html_string(text)
|
||||
self.assertEqual(len(blocks), 1)
|
||||
|
||||
words = list(blocks[0].words())
|
||||
words = list(blocks[0].words_iter())
|
||||
|
||||
# Find words that should be both bold and italic
|
||||
bold_italic_words = [w for _, w in words
|
||||
@@ -163,7 +163,7 @@ class TestHTMLStyledParagraphs(unittest.TestCase):
|
||||
blocks = parse_html_string(text)
|
||||
self.assertEqual(len(blocks), 1)
|
||||
|
||||
words = list(blocks[0].words())
|
||||
words = list(blocks[0].words_iter())
|
||||
|
||||
# Check for hex red color
|
||||
hex_red_words = [w for _, w in words if w.style.colour == (255, 0, 0)]
|
||||
@@ -206,7 +206,7 @@ class TestHTMLBlockElements(unittest.TestCase):
|
||||
self.assertIsInstance(block, Heading)
|
||||
self.assertEqual(block.level, expected_levels[i])
|
||||
|
||||
words = list(block.words())
|
||||
words = list(block.words_iter())
|
||||
self.assertEqual(len(words), 2) # "Heading" and number
|
||||
self.assertEqual(words[0][1].text, "Heading")
|
||||
|
||||
@@ -264,7 +264,7 @@ class TestHTMLBlockElements(unittest.TestCase):
|
||||
# Check second item has bold text
|
||||
second_item_blocks = list(items[1].blocks())
|
||||
if second_item_blocks:
|
||||
words = list(second_item_blocks[0].words())
|
||||
words = list(second_item_blocks[0].words_iter())
|
||||
bold_words = [w for _, w in words if w.style.weight == FontWeight.BOLD]
|
||||
self.assertGreater(len(bold_words), 0)
|
||||
|
||||
@@ -470,7 +470,7 @@ class TestHTMLFontRegistryIntegration(unittest.TestCase):
|
||||
|
||||
# Extract all words from the paragraph
|
||||
paragraph = blocks[0]
|
||||
words = list(paragraph.words())
|
||||
words = list(paragraph.words_iter())
|
||||
|
||||
# Find words with different styles
|
||||
normal_words = [w for _, w in words if w.style.weight == FontWeight.NORMAL
|
||||
@@ -545,7 +545,7 @@ class TestHTMLFontRegistryIntegration(unittest.TestCase):
|
||||
|
||||
# Should create styles for different style combinations
|
||||
paragraph = blocks[0]
|
||||
words = list(paragraph.words())
|
||||
words = list(paragraph.words_iter())
|
||||
|
||||
# Find words that are both bold and italic
|
||||
bold_italic_words = [w for _, w in words
|
||||
|
||||
Reference in New Issue
Block a user