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