from beautifulsoup.builder.html5lib_builder import HTML5TreeBuilder from test_lxml import ( TestLXMLBuilder, TestLXMLBuilderInvalidMarkup, ) class TestHTML5Builder(TestLXMLBuilder): """See `BuilderSmokeTest`.""" @property def default_builder(self): return HTML5TreeBuilder() def test_bare_string(self): # A bare string is turned into some kind of HTML document or # fragment recognizable as the original string. # # In this case, lxml puts a
tag around the bare string. self.assertSoupEquals( "A bare string", "A bare string") def test_correctly_nested_tables(self): markup = ('
Here's another table:"
'
| ')
self.assertSoupEquals(
markup,
'
Here\'s another table:'
'
|
Foo |
Bar |
Baz |
") self.assertSoupEquals(" ") class TestHTML5BuilderInvalidMarkup(TestLXMLBuilderInvalidMarkup): """See `BuilderInvalidMarkupSmokeTest`.""" @property def default_builder(self): return HTML5TreeBuilder() def test_unclosed_block_level_elements(self): # The unclosed tag is closed so that the block-level tag # can be closed, and another tag is inserted after the # next block-level tag begins. self.assertSoupEquals( '
Foo
Bar', '
Foo
Bar
') def test_table_containing_bare_markup(self): # Markup should be in table cells, not directly in the table. self.assertSoupEquals("