MCPcopy Create free account
hub / github.com/LLMQuant/quant-mind / HtmlToMarkdownTests

Class HtmlToMarkdownTests

tests/preprocess/format/test_html.py:11–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9
10
11class HtmlToMarkdownTests(unittest.IsolatedAsyncioTestCase):
12 async def test_extracts_article_body(self):
13 html = _FIXTURE.read_text(encoding="utf-8")
14 markdown = await html_to_markdown(html)
15 self.assertTrue(markdown.strip(), "expected non-empty markdown output")
16 # Strict-precision mode should keep the article paragraphs and drop
17 # the nav / footer chrome.
18 self.assertIn("trafilatura", markdown)
19
20 async def test_strips_boilerplate_by_default(self):
21 html = _FIXTURE.read_text(encoding="utf-8")
22 markdown = await html_to_markdown(html)
23 # Footer copyright string should be gone in strict mode.
24 self.assertNotIn("Cookie policy", markdown)
25
26 async def test_returns_string(self):
27 html = _FIXTURE.read_text(encoding="utf-8")
28 markdown = await html_to_markdown(html)
29 self.assertIsInstance(markdown, str)
30
31 async def test_empty_html_returns_empty_string(self):
32 result = await html_to_markdown(" ")
33 self.assertEqual(result, "")
34
35 async def test_unparseable_returns_empty_string(self):
36 # A bare snippet with no extractable article body — trafilatura
37 # returns None which our wrapper translates to "".
38 result = await html_to_markdown("<html><body></body></html>")
39 self.assertEqual(result, "")

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected