blob: b45e35f9998bcdee334e5515adb5a0dbe0c79ccf [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001"""Tests to ensure that the html.parser tree builder generates good
2trees."""
3
4from pdb import set_trace
5import pickle
6from bs4.testing import SoupTest, HTMLTreeBuilderSmokeTest
7from bs4.builder import HTMLParserTreeBuilder
8
9class HTMLParserTreeBuilderSmokeTest(SoupTest, HTMLTreeBuilderSmokeTest):
10
11 @property
12 def default_builder(self):
13 return HTMLParserTreeBuilder()
14
15 def test_namespaced_system_doctype(self):
16 # html.parser can't handle namespaced doctypes, so skip this one.
17 pass
18
19 def test_namespaced_public_doctype(self):
20 # html.parser can't handle namespaced doctypes, so skip this one.
21 pass
22
23 def test_builder_is_pickled(self):
24 """Unlike most tree builders, HTMLParserTreeBuilder and will
25 be restored after pickling.
26 """
27 tree = self.soup("<a><b>foo</a>")
28 dumped = pickle.dumps(tree, 2)
29 loaded = pickle.loads(dumped)
30 self.assertTrue(isinstance(loaded.builder, type(tree.builder)))
31
32