MCPcopy Create free account
hub / github.com/awolverp/markupever / test_serialize

Function test_serialize

python/tests/test_rustlib.py:563–598  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

561
562
563def test_serialize():
564 parser = rl.Parser(rl.HtmlOptions(full_document=True))
565 for c in ("<html>", b"<body>Ali</body>", b"</html>"):
566 parser.process(c)
567 parser.finish()
568
569 dom = parser.into_dom()
570
571 assert rl.serialize(dom.root(), 0) == b"<html><head></head><body>Ali</body></html>"
572 assert (
573 rl.serialize(dom.root(), 0, is_html=False)
574 == b'<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>Ali</body></html>'
575 )
576
577 parser = rl.Parser(rl.HtmlOptions(full_document=False))
578 for c in ("<hello>", b"Ali", b"</hello>"):
579 parser.process(c)
580 parser.finish()
581
582 dom = parser.into_dom()
583
584 assert rl.serialize(dom.root(), 0, is_html=True) == b"<html><hello>Ali</hello></html>"
585 assert (
586 rl.serialize(dom.root(), 0, is_html=False)
587 == b'<html xmlns="http://www.w3.org/1999/xhtml"><hello>Ali</hello></html>'
588 )
589
590 parser = rl.Parser(rl.XmlOptions())
591 for c in ("<hello>", b"Ali", b"</hello>"):
592 parser.process(c)
593 parser.finish()
594
595 dom = parser.into_dom()
596
597 assert rl.serialize(dom.root(), 0) == b"<hello>Ali</hello>"
598 assert rl.serialize(dom.root(), 0, is_html=False) == b"<hello>Ali</hello>"

Callers

nothing calls this directly

Calls 5

processMethod · 0.95
finishMethod · 0.95
into_domMethod · 0.95
serializeMethod · 0.45
rootMethod · 0.45

Tested by

no test coverage detected