Test reduce_html at reduction level 2 (further reducing text content and decomposing style tags).
()
| 118 | |
| 119 | |
| 120 | def test_reduce_html_reduction_2(): |
| 121 | """Test reduce_html at reduction level 2 (further reducing text content and decomposing style tags).""" |
| 122 | raw_html = """ |
| 123 | <html> |
| 124 | <head> |
| 125 | <style>.unused { color: blue; }</style> |
| 126 | </head> |
| 127 | <body> |
| 128 | <p> Long text with more than twenty characters. Extra content. </p> |
| 129 | </body> |
| 130 | </html> |
| 131 | """ |
| 132 | reduced = reduce_html(raw_html, 2) |
| 133 | # For level 2, text should be truncated to the first 20 characters after normalization. |
| 134 | # The original text "Long text with more than twenty characters. Extra content." |
| 135 | # normalized becomes "Long text with more than twenty characters. Extra content." |
| 136 | # and then truncated to: "Long text with more t" (first 20 characters) |
| 137 | assert "Long text with more t" in reduced |
| 138 | # Confirm that style tags contents are completely removed |
| 139 | assert ".unused" not in reduced |
| 140 | |
| 141 | |
| 142 | def test_reduce_html_no_body(): |
nothing calls this directly
no test coverage detected