From 87747b712cfe63d173332f06ee1ba2bf9adf9ce5 Mon Sep 17 00:00:00 2001 From: Leonard Richardson Date: Wed, 15 Feb 2012 17:03:37 -0500 Subject: Added a kind of hacky way to interpret the restriction class='foo bar'. Stop generating a space before the slash that closes an empty-element tag. --- bs4/tests/test_lxml.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'bs4/tests/test_lxml.py') diff --git a/bs4/tests/test_lxml.py b/bs4/tests/test_lxml.py index 359f619..3603528 100644 --- a/bs4/tests/test_lxml.py +++ b/bs4/tests/test_lxml.py @@ -38,10 +38,10 @@ class TestLXMLBuilder(SoupTest): def test_empty_element(self): # HTML's empty-element tags are recognized as such. self.assertSoupEquals( - "

A tag

", "

A tag

") + "

A tag

", "

A tag

") self.assertSoupEquals( - "

Foo
bar

", "

Foo
bar

") + "

Foo
bar

", "

Foo
bar

") def test_empty_tag_thats_not_an_empty_element_tag(self): # A tag that is empty but not an HTML empty-element tag @@ -218,7 +218,7 @@ class TestLXMLBuilder(SoupTest): # easy-to-understand document. # Here it is in Unicode. Note that it claims to be in ISO-Latin-1. - unicode_html = u'

Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!

' + unicode_html = u'

Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!

' # That's because we're going to encode it into ISO-Latin-1, and use # that to test. @@ -263,12 +263,12 @@ class TestLXMLBuilder(SoupTest): # Here's the tag saying that a document is # encoded in Shift-JIS. meta_tag = ('') + 'http-equiv="Content-type"/>') # Here's a document incorporating that meta tag. shift_jis_html = ( '\n%s\n' - '' + '' 'Shift-JIS markup goes here.') % meta_tag soup = self.soup(shift_jis_html) @@ -293,17 +293,17 @@ class TestLXMLBuilder(SoupTest): """A
tag is designated as an empty-element tag.""" soup = self.soup("

") self.assertTrue(soup.br.is_empty_element) - self.assertEqual(str(soup.br), "
") + self.assertEqual(str(soup.br), "
") def test_p_tag_is_not_empty_element(self): """A

tag is not designated as an empty-element tag.""" - soup = self.soup("

") + soup = self.soup("

") self.assertFalse(soup.p.is_empty_element) self.assertEqual(str(soup.p), "

") def test_soupstrainer(self): strainer = SoupStrainer("b") - soup = self.soup("A bold statement", + soup = self.soup("A bold statement", parse_only=strainer) self.assertEqual(soup.decode(), "bold") @@ -370,7 +370,7 @@ class TestLXMLBuilderInvalidMarkup(SoupTest): # the 'close' tag is ignored. self.assertSoupEquals( "http://foo.com/", - "http://foo.com/") + "http://foo.com/") def test_boolean_attribute_with_no_value_gets_empty_value(self): soup = self.soup("
foo
") @@ -391,7 +391,7 @@ class TestLXMLBuilderInvalidMarkup(SoupTest): self.assertEqual(markup.p.contents, ["this is the definition:"]) def test_empty_element_tag_with_contents(self): - self.assertSoupEquals("
foo
", "
foo") + self.assertSoupEquals("
foo
", "
foo") def test_doctype_in_body(self): markup = "

onetwo

" @@ -556,8 +556,8 @@ class TestLXMLXMLBuilder(SoupTest): # Mixed-case tags are *not* folded to lowercase, but the # end tag is always the same case as the start tag. self.assertSoupEquals( - "", - "") + "", + "") def test_cdata_becomes_text(self): @@ -572,10 +572,10 @@ class TestLXMLXMLBuilder(SoupTest): def test_can_handle_invalid_xml(self): - self.assertSoupEquals("", "") + self.assertSoupEquals("", "") def test_empty_element_tag(self): - soup = self.soup("

") + soup = self.soup("

") self.assertTrue(soup.iamselfclosing.is_empty_element) def test_self_empty_tag_treated_as_empty_element(self): @@ -587,7 +587,7 @@ class TestLXMLXMLBuilder(SoupTest): self.assertFalse(soup.ihavecontents.is_empty_element) def test_empty_tag_that_stops_being_empty_gets_a_closing_tag(self): - soup = self.soup("") + soup = self.soup("") self.assertTrue(soup.bar.is_empty_element) soup.bar.insert(1, "Contents") self.assertFalse(soup.bar.is_empty_element) @@ -597,12 +597,12 @@ class TestLXMLXMLBuilder(SoupTest): builder = LXMLTreeBuilderForXML(empty_element_tags=['bar']) soup = BeautifulSoup(builder=builder, markup="") self.assertTrue(soup.bar.is_empty_element) - self.assertEqual(str(soup), self.document_for("")) + self.assertEqual(str(soup), self.document_for("")) def test_empty_tag_not_in_empty_element_tag_list_has_closing_tag(self): builder = LXMLTreeBuilderForXML(empty_element_tags=['bar']) - soup = BeautifulSoup(builder=builder, markup="") + soup = BeautifulSoup(builder=builder, markup="") self.assertFalse(soup.foo.is_empty_element) self.assertEqual(str(soup), self.document_for("")) -- cgit v1.2.3