summaryrefslogtreecommitdiff
path: root/tests/test_html5lib.py
diff options
context:
space:
mode:
authorLeonard Richardson <leonard.richardson@canonical.com>2011-02-10 13:13:50 -0500
committerLeonard Richardson <leonard.richardson@canonical.com>2011-02-10 13:13:50 -0500
commitd444427275459c6be2dc255274831bae26eb5e04 (patch)
treeb93a4ffe35ae9519a4331d42580c2c2841c89409 /tests/test_html5lib.py
parent261f981dc4e62a41bb0e85285d1f40927b34e3d3 (diff)
Added more table tests.
Diffstat (limited to 'tests/test_html5lib.py')
-rw-r--r--tests/test_html5lib.py40
1 files changed, 19 insertions, 21 deletions
diff --git a/tests/test_html5lib.py b/tests/test_html5lib.py
index ef38f9f..5febe2d 100644
--- a/tests/test_html5lib.py
+++ b/tests/test_html5lib.py
@@ -19,31 +19,24 @@ class TestHTML5Builder(TestLXMLBuilder):
self.assertSoupEquals(
"A bare string", "A bare string")
- def test_nested_tables(self):
- # See TestLXMLBuilder for TABLE_MARKUP_1 and
- # TABLE_MARKUP_2. They're both nested tables where the
- # top-level <table> and <tr> aren't closed. In TABLE_MARKUP_1
- # the second table is within a <td> tag. In
- # TABLE_MARKUP_2, the second table is floating inside a <tr> tag.
- #
- # html5lib adds <tbody> tags to each table. It treats
- # TABLE_MARKUP_1 as a nested table, and TABLE_MARKUP_2 as two
- # different tables.
+ def test_correctly_nested_tables(self):
+ markup = ('<table id="1">'
+ '<tr>'
+ "<td>Here's another table:"
+ '<table id="2">'
+ '<tr><td>foo</td></tr>'
+ '</table></td>')
+
self.assertSoupEquals(
- self.TABLE_MARKUP_1,
- '<table id="1"><tbody>'
- "<tr><td>Here's another table:"
+ markup,
+ '<table id="1"><tbody><tr><td>Here\'s another table:'
'<table id="2"><tbody><tr><td>foo</td></tr></tbody></table>'
- "</td></tr></tbody></table>"
- )
+ '</td></tr></tbody></table>')
self.assertSoupEquals(
- self.TABLE_MARKUP_2,
- '<table id="1"><tbody>'
- "<tr><td>Here's another table:</td></tr>"
- '</tbody></table>'
- '<table id="2"><tbody><tr><td>foo</td></tr></tbody></table>'
- )
+ "<table><thead><tr><td>Foo</td></tr></thead>"
+ "<tbody><tr><td>Bar</td></tr></tbody>"
+ "<tfoot><tr><td>Baz</td></tr></tfoot></table>")
def test_collapsed_whitespace(self):
"""Whitespace is preserved even in tags that don't require it."""
@@ -66,6 +59,11 @@ class TestHTML5BuilderInvalidMarkup(TestLXMLBuilderInvalidMarkup):
'<blockquote><p><b>Foo</blockquote><p>Bar',
'<blockquote><p><b>Foo</b></p></blockquote><p><b>Bar</b></p>')
+ def test_table_containing_bare_markup(self):
+ # Markup should be in table cells, not directly in the table.
+ self.assertSoupEquals("<table><div>Foo</div></table>",
+ "<div>Foo</div><table></table>")
+
def test_incorrectly_nested_tables(self):
self.assertSoupEquals(
'<table><tr><table><tr id="nested">',