diff options
author | Leonard Richardson <leonard.richardson@canonical.com> | 2012-02-21 08:05:17 -0500 |
---|---|---|
committer | Leonard Richardson <leonard.richardson@canonical.com> | 2012-02-21 08:05:17 -0500 |
commit | ab5cfcead94a0c99d0f325883960097ef223fca6 (patch) | |
tree | be531463bd32fe82273ed97d4916ffcefd0e41fb /bs4/tests/test_tree.py | |
parent | e1b321db7331752a3aea8dd7070dd0db4c60c51d (diff) | |
parent | 60cb51632dce022d1a4aff18500d286e58e0bd5c (diff) |
Merged from trunk.
Diffstat (limited to 'bs4/tests/test_tree.py')
-rw-r--r-- | bs4/tests/test_tree.py | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/bs4/tests/test_tree.py b/bs4/tests/test_tree.py index 70a7da1..f39826a 100644 --- a/bs4/tests/test_tree.py +++ b/bs4/tests/test_tree.py @@ -14,9 +14,18 @@ import pickle import re import warnings from bs4 import BeautifulSoup -from bs4.builder import builder_registry +from bs4.builder import ( + builder_registry, + HTMLParserTreeBuilder, +) from bs4.element import CData, NavigableString, SoupStrainer, Tag -from bs4.testing import SoupTest +from bs4.testing import ( + SoupTest, + skipIf, +) + +XML_BUILDER_PRESENT = (builder_registry.lookup("xml") is not None) +LXML_PRESENT = (builder_registry.lookup("lxml") is not None) class TreeTest(SoupTest): @@ -600,14 +609,15 @@ class TestTagCreation(SoupTest): self.assertEqual(None, new_tag.parent) def test_tag_inherits_self_closing_rules_from_builder(self): - xml_soup = BeautifulSoup("", "xml") - xml_br = xml_soup.new_tag("br") - xml_p = xml_soup.new_tag("p") + if XML_BUILDER_PRESENT: + xml_soup = BeautifulSoup("", "xml") + xml_br = xml_soup.new_tag("br") + xml_p = xml_soup.new_tag("p") - # Both the <br> and <p> tag are empty-element, just because - # they have no contents. - self.assertEqual(b"<br/>", xml_br.encode()) - self.assertEqual(b"<p/>", xml_p.encode()) + # Both the <br> and <p> tag are empty-element, just because + # they have no contents. + self.assertEqual(b"<br/>", xml_br.encode()) + self.assertEqual(b"<p/>", xml_p.encode()) html_soup = BeautifulSoup("", "html") html_br = html_soup.new_tag("br") @@ -1000,10 +1010,6 @@ class TestElementObjects(SoupTest): markup = '<b a="1" z="5" m="3" f="2" y="4"></b>' self.assertSoupEquals(markup, '<b a="1" f="2" m="3" y="4" z="5"></b>') - def test_multiple_values_for_the_same_attribute_are_collapsed(self): - markup = '<b b="20" a="1" b="10" a="2" a="3" a="4"></b>' - self.assertSoupEquals(markup, '<b a="1" b="20"></b>') - def test_string(self): # A tag that contains only a text node makes that node # available as .string. |