rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | """Tests to ensure that the html.parser tree builder generates good |
| 2 | trees.""" |
| 3 | |
| 4 | from pdb import set_trace |
| 5 | import pickle |
| 6 | from bs4.testing import SoupTest, HTMLTreeBuilderSmokeTest |
| 7 | from bs4.builder import HTMLParserTreeBuilder |
| 8 | |
| 9 | class 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 | |