"
soup = self.soup(markup)
data = soup.find(text="[CDATA[foo]]")
self.assertEquals(data.__class__, Comment)
def test_nonsensical_declaration(self):
# Declarations that don't make any sense are turned into comments.
soup = self.soup('
a
')
self.assertEquals(str(soup),
(""
"
a
"))
soup = self.soup('
a
')
self.assertEquals(str(soup),
("
a
"
""))
def test_whitespace_in_doctype(self):
# A declaration that has extra whitespace is turned into a comment.
soup = self.soup((
''
'
foo
'))
self.assertEquals(
str(soup),
(''
'
foo
'))
def test_incomplete_declaration(self):
# An incomplete declaration is treated as a comment.
markup = 'ac'
self.assertSoupEquals(markup, "ac")
# Let's spell that out a little more explicitly.
soup = self.soup(markup)
str1, comment, str2 = soup.body.contents
self.assertEquals(str1, 'a')
self.assertEquals(comment.__class__, Comment)
self.assertEquals(comment, 'b
Sacr\xe9 bleu!