diff options
author | Leonard Richardson <leonard.richardson@canonical.com> | 2010-12-29 19:00:46 -0500 |
---|---|---|
committer | Leonard Richardson <leonard.richardson@canonical.com> | 2010-12-29 19:00:46 -0500 |
commit | 484284c0c80aa749ee3050a3194d7bc99cf2916b (patch) | |
tree | 0340301efd77fa122f14a14736ec096524817917 | |
parent | 3e79613458960499d2bce45d4db0d0e96d8e2ffe (diff) |
Moved in a test for comments (not supported by the html5lib treebuilder yet.
-rw-r--r-- | src/beautifulsoup/tests/helpers.py | 11 | ||||
-rw-r--r-- | src/beautifulsoup/tests/test_soup.py | 2 |
2 files changed, 11 insertions, 2 deletions
diff --git a/src/beautifulsoup/tests/helpers.py b/src/beautifulsoup/tests/helpers.py index c62bb48..c8189e3 100644 --- a/src/beautifulsoup/tests/helpers.py +++ b/src/beautifulsoup/tests/helpers.py @@ -2,7 +2,7 @@ import unittest from beautifulsoup import BeautifulSoup -from beautifulsoup.element import SoupStrainer +from beautifulsoup.element import Comment, SoupStrainer from beautifulsoup.builder.lxml_builder import LXMLTreeBuilder class SoupTest(unittest.TestCase): @@ -63,6 +63,15 @@ class BuilderSmokeTest(SoupTest): self.assertSoupEquals( "<p>Foo<br/>bar</p>", "<p>Foo<br />bar</p>") + def test_comment(self): + # Comments are represented as Comment objects. + markup = "<p>foo<!--foobar-->baz</p>" + self.assertSoupEquals(markup) + + soup = self.soup(markup) + comment = soup.find(text="foobar") + self.assertEquals(comment.__class__, Comment) + def test_nested_inline_elements(self): # Inline tags can be nested indefinitely. b_tag = "<b>Inside a B tag</b>" diff --git a/src/beautifulsoup/tests/test_soup.py b/src/beautifulsoup/tests/test_soup.py index f8d3970..c5b08bb 100644 --- a/src/beautifulsoup/tests/test_soup.py +++ b/src/beautifulsoup/tests/test_soup.py @@ -5,6 +5,7 @@ import unittest from helpers import SoupTest from beautifulsoup.dammit import UnicodeDammit + class TestEncodingConversion(SoupTest): # Test Beautiful Soup's ability to decode and encode from various # encodings. @@ -46,7 +47,6 @@ class TestEncodingConversion(SoupTest): soup_from_unicode = self.soup(self.unicode_data) self.assertEquals(soup_from_unicode.encode('utf-8'), self.utf8_data) - class TestUnicodeDammit(unittest.TestCase): """Standalone tests of Unicode, Dammit.""" |