From 86ae2ed0a644f124475a4aff3b34e229f5b7ec8f Mon Sep 17 00:00:00 2001 From: Leonard Richardson Date: Sat, 19 Feb 2011 21:16:20 -0500 Subject: Set up an lxml parser that only parses XML, though it's not very functional yet. --- tests/test_lxml.py | 6 +++--- tests/test_tree.py | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/test_lxml.py b/tests/test_lxml.py index 7e15dcf..7597552 100644 --- a/tests/test_lxml.py +++ b/tests/test_lxml.py @@ -131,7 +131,7 @@ class TestLXMLBuilder(SoupTest): # But, both lxml and html5lib do their best to parse the # contents of a ' - soup = BeautifulSoup(text) + soup = self.soup(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') @@ -141,7 +141,7 @@ class TestLXMLBuilder(SoupTest): # The contents of a ' % javascript) + soup = self.soup('' % javascript) self.assertEquals(soup.script.string, javascript) def test_naked_ampersands(self): @@ -300,7 +300,7 @@ class TestLXMLBuilder(SoupTest): def test_entities_converted_on_the_way_out(self): text = "

<<sacré bleu!>>

" expected = u"<<sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!>>".encode("utf-8") - soup = BeautifulSoup(text) + soup = self.soup(text) str = soup.p.string #self.assertEquals(str.encode("utf-8"), expected) diff --git a/tests/test_tree.py b/tests/test_tree.py index 02efead..233cb3c 100644 --- a/tests/test_tree.py +++ b/tests/test_tree.py @@ -524,7 +524,7 @@ class TestTreeModification(SoupTest): def test_new_tag_creation(self): builder = BeautifulSoup.default_builder() - soup = BeautifulSoup("", builder=builder) + soup = self.soup("", builder=builder) a = Tag(soup, builder, 'a') ol = Tag(soup, builder, 'ol') a['href'] = 'http://foo.com/' @@ -553,7 +553,7 @@ class TestTreeModification(SoupTest): def test_replace_tag_with_itself(self): text = "Foo" - soup = BeautifulSoup(text) + soup = self.soup(text) c = soup.c soup.c.replaceWith(c) self.assertEquals(soup.decode(), self.document_for(text)) @@ -592,7 +592,7 @@ class TestTreeModification(SoupTest): def test_insert_tag(self): builder = self.default_builder - soup = BeautifulSoup( + soup = self.soup( "Findlady!", builder=builder) magic_tag = Tag(soup, builder, 'magictag') magic_tag.insert(0, "the") @@ -636,7 +636,7 @@ class TestTreeModification(SoupTest): self.assertEquals(no.nextSibling, " business") def test_nested_tag_replace_with(self): - soup = BeautifulSoup( + soup = self.soup( """Wereservetherighttorefuseservice""") # Replace the entire tag and its contents ("reserve the @@ -853,7 +853,7 @@ class TestSubstitutions(SoupTest): # meta tag got filtered out by the strainer. This test makes # sure that doesn't happen. strainer = SoupStrainer('pre') - soup = BeautifulSoup(markup, parseOnlyThese=strainer) + soup = self.soup(markup, parseOnlyThese=strainer) self.assertEquals(soup.contents[0].name, 'pre') -- cgit v1.2.3