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

Function test_parser_generators

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

Source from the content-addressed store, hash-verified

42
43
44def test_parser_generators():
45 parser = rl.Parser(rl.HtmlOptions())
46 parser.process(b"<html><p>Ali</p></html>")
47 parser.finish()
48
49 repr(parser)
50
51 parser = rl.Parser(rl.HtmlOptions())
52 parser.process("<html><p>Ali</p></html>")
53
54 repr(parser)
55
56 with pytest.raises(TypeError):
57 parser.process(1)
58
59 with pytest.raises(RuntimeError):
60 parser.into_dom()
61
62 parser.finish()
63
64 with pytest.raises(RuntimeError):
65 parser.process("")
66
67 with pytest.raises(RuntimeError):
68 parser.finish()
69
70 parser.into_dom()
71 with pytest.raises(RuntimeError):
72 parser.into_dom()
73
74 parser = rl.Parser(rl.XmlOptions())
75 for c in ("<html>", b"Ali", b"</html>"):
76 parser.process(c)
77 parser.finish()
78
79 assert isinstance(parser.errors(), list)
80 assert parser.lineno() == 1
81 assert parser.quirks_mode() == 2
82
83 parser = rl.Parser(rl.HtmlOptions(full_document=False))
84 for c in (b"<html><p>Ali</p>", "\n", "</html>"):
85 parser.process(c)
86 parser.finish()
87
88 assert parser.lineno() == 2
89
90 _ = parser.into_dom()
91
92 repr(parser)
93
94 with pytest.raises(RuntimeError):
95 parser.errors()
96
97
98def test_document():

Callers

nothing calls this directly

Calls 6

processMethod · 0.95
finishMethod · 0.95
into_domMethod · 0.95
errorsMethod · 0.95
linenoMethod · 0.95
quirks_modeMethod · 0.95

Tested by

no test coverage detected