MCPcopy Index your code
hub / github.com/grapeot/devin.cursorrules / test_parse_html

Method test_parse_html

tests/test_web_scraper.py:44–88  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

42 self.assertFalse(validate_url(''))
43
44 def test_parse_html(self):
45 # Test with empty or None input
46 self.assertEqual(parse_html(None), "")
47 self.assertEqual(parse_html(""), "")
48
49 # Test with simple HTML
50 html = """
51 <html>
52 <body>
53 <h1>Title</h1>
54 <p>Paragraph text</p>
55 <a href="https://example.com">Link text</a>
56 <script>var x = 1;</script>
57 <style>.css { color: red; }</style>
58 </body>
59 </html>
60 """
61 result = parse_html(html)
62 self.assertIn("Title", result)
63 self.assertIn("Paragraph text", result)
64 self.assertIn("[Link text](https://example.com)", result)
65 self.assertNotIn("var x = 1", result) # Script content should be filtered
66 self.assertNotIn(".css", result) # Style content should be filtered
67
68 # Test with nested elements
69 html = """
70 <html>
71 <body>
72 <div>
73 <p>Level 1</p>
74 <div>
75 <p>Level 2</p>
76 </div>
77 </div>
78 </body>
79 </html>
80 """
81 result = parse_html(html)
82 self.assertIn("Level 1", result)
83 self.assertIn("Level 2", result)
84
85 # Test with malformed HTML
86 html = "<p>Unclosed paragraph"
87 result = parse_html(html)
88 self.assertIn("Unclosed paragraph", result)
89
90 async def test_fetch_page(self):
91 """Test fetching a single page."""

Callers

nothing calls this directly

Calls 1

parse_htmlFunction · 0.90

Tested by

no test coverage detected