from beautifulsoup.builder.html5lib_builder import HTML5TreeBuilder
from beautifulsoup.element import Comment
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:"
'
'
'
foo
'
'
')
self.assertSoupEquals(
markup,
'
Here\'s another table:'
'
foo
'
'
')
self.assertSoupEquals(
"
Foo
"
"
Bar
"
"
Baz
")
def test_collapsed_whitespace(self):
"""Whitespace is preserved even in tags that don't require it."""
self.assertSoupEquals("
")
self.assertSoupEquals("")
def test_cdata_where_its_ok(self):
# In html5lib 0.9.0, all CDATA sections are converted into
# comments. In a later version (unreleased as of this
# writing), CDATA sections in tags like