From bc97bb3a83ee9fb4c8e31d11069ccf1cda61d4ff Mon Sep 17 00:00:00 2001 From: Leonard Richardson Date: Sun, 13 Feb 2011 19:59:44 -0500 Subject: Added tests of nonsensical declarations. --- tests/test_html5lib.py | 13 +++++++++++++ tests/test_lxml.py | 5 +++-- 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/test_html5lib.py b/tests/test_html5lib.py index 2d16bbb..48f27ae 100644 --- a/tests/test_html5lib.py +++ b/tests/test_html5lib.py @@ -95,6 +95,19 @@ class TestHTML5BuilderInvalidMarkup(TestLXMLBuilderInvalidMarkup): 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_foo(self): isolatin = """Sacr\xe9 bleu!""" soup = self.soup(isolatin) diff --git a/tests/test_lxml.py b/tests/test_lxml.py index 028b956..cba5522 100644 --- a/tests/test_lxml.py +++ b/tests/test_lxml.py @@ -298,8 +298,9 @@ class TestLXMLBuilderInvalidMarkup(SoupTest): markup = "

onetwo

" self.assertSoupEquals(markup) - #def testJunkInDeclaration(self): - # self.assertSoupEquals('a', 'a') + def test_nonsensical_declaration(self): + # Declarations that don't make any sense are ignored. + self.assertSoupEquals('

a

', "

a

") def test_cdata_where_it_doesnt_belong(self): #CDATA sections are ignored. -- cgit v1.2.3