diff options
author | Leonard Richardson <leonard.richardson@canonical.com> | 2011-02-13 19:59:44 -0500 |
---|---|---|
committer | Leonard Richardson <leonard.richardson@canonical.com> | 2011-02-13 19:59:44 -0500 |
commit | bc97bb3a83ee9fb4c8e31d11069ccf1cda61d4ff (patch) | |
tree | bf0637e79bc667a1b5ae08ca4794df414f169992 | |
parent | a011baa0e95e3d42d647cdf68164ba1c30314492 (diff) |
Added tests of nonsensical declarations.
-rw-r--r-- | tests/test_html5lib.py | 13 | ||||
-rw-r--r-- | tests/test_lxml.py | 5 |
2 files changed, 16 insertions, 2 deletions
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('<! Foo = -8><p>a</p>') + self.assertEquals(str(soup), + ("<!-- Foo = -8-->" + "<html><head></head><body><p>a</p></body></html>")) + + soup = self.soup('<p>a</p><! Foo = -8>') + self.assertEquals(str(soup), + ("<html><head></head><body><p>a</p>" + "<!-- Foo = -8--></body></html>")) + + def test_foo(self): isolatin = """<html><meta http-equiv="Content-type" content="text/html; charset=ISO-Latin-1" />Sacr\xe9 bleu!</html>""" 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 = "<p>one<!DOCTYPE foobar>two</p>" self.assertSoupEquals(markup) - #def testJunkInDeclaration(self): - # self.assertSoupEquals('<! Foo = -8>a', '<!Foo = -8>a') + def test_nonsensical_declaration(self): + # Declarations that don't make any sense are ignored. + self.assertSoupEquals('<! Foo = -8><p>a</p>', "<p>a</p>") def test_cdata_where_it_doesnt_belong(self): #CDATA sections are ignored. |