summaryrefslogtreecommitdiff
path: root/beautifulsoup/testing.py
diff options
context:
space:
mode:
authorLeonard Richardson <leonard.richardson@canonical.com>2011-01-29 00:23:43 -0500
committerLeonard Richardson <leonard.richardson@canonical.com>2011-01-29 00:23:43 -0500
commit04e658f7036a4889a5a0f307c9860adf049f8eca (patch)
tree31a3c1782a1ca855fd9294333871e61a904f72a0 /beautifulsoup/testing.py
parent7a6f07b1650eaba61d4c669feb5565cf443b2531 (diff)
parentac851828df94b49769f7bed38cca6182a60540f5 (diff)
Ported even more tests.
Diffstat (limited to 'beautifulsoup/testing.py')
-rw-r--r--beautifulsoup/testing.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/beautifulsoup/testing.py b/beautifulsoup/testing.py
index eea14f0..9d0fa3a 100644
--- a/beautifulsoup/testing.py
+++ b/beautifulsoup/testing.py
@@ -119,6 +119,26 @@ class BuilderSmokeTest(SoupTest):
self.assertSoupEquals('<this is="really messed up & stuff"></this>',
'<this is="really messed up &amp; stuff"></this>')
+ def test_literal_in_textarea(self):
+ # Anything inside a <textarea> is supposed to be treated as
+ # the literal value of the field, (XXX citation needed).
+ #
+ # But, both lxml and html5lib do their best to parse the
+ # contents of a <textarea> as HTML.
+ text = '<textarea>Junk like <b> tags and <&<&amp;</textarea>'
+ soup = BeautifulSoup(text)
+ self.assertEquals(len(soup.textarea.contents), 2)
+ self.assertEquals(soup.textarea.contents[0], u"Junk like ")
+ self.assertEquals(soup.textarea.contents[1].name, 'b')
+ self.assertEquals(soup.textarea.b.string, u" tags and ")
+
+ def test_literal_in_script(self):
+ # The contents of a <script> tag are treated as a literal string,
+ # even if that string contains HTML.
+ javascript = 'if (i < 2) { alert("<b>foo</b>"); }'
+ soup = BeautifulSoup('<script>%s</script>' % javascript)
+ self.assertEquals(soup.script.string, javascript)
+
class BuilderInvalidMarkupSmokeTest(SoupTest):
"""Tests of invalid markup.