From d18cebdeffafb4e4c9c6239da2b3ae94ae5a42e8 Mon Sep 17 00:00:00 2001 From: Leonard Richardson Date: Wed, 29 Dec 2010 11:52:00 -0500 Subject: Ported some tests from the old system to the new smoke test class. --- src/beautifulsoup/tests/helpers.py | 50 +++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 4 deletions(-) (limited to 'src/beautifulsoup/tests/helpers.py') diff --git a/src/beautifulsoup/tests/helpers.py b/src/beautifulsoup/tests/helpers.py index a4156cd..fbdcedb 100644 --- a/src/beautifulsoup/tests/helpers.py +++ b/src/beautifulsoup/tests/helpers.py @@ -66,15 +66,43 @@ class BuilderSmokeTest(SoupTest): self.assertEqual(blockquote.p.b.string, 'Foo') self.assertEqual(blockquote.b.string, 'Foo') + def test_collapsed_whitespace(self): + """In most tags, whitespace is collapsed.""" + self.assertSoupEquals("

", "

") + + def test_preserved_whitespace_in_pre_and_textarea(self): + """In
 and ")
+
+
+    def test_single_quote_attribute_values_become_double_quotes(self):
+        self.assertSoupEquals("",
+                              '')
+
+    def test_attribute_values_with_nested_quotes_are_left_alone(self):
+        text = """a"""
+        self.assertSoupEquals(text)
+
+    def test_attribute_values_with_double_nested_quotes_get_quoted(self):
+        text = """a"""
+        soup = self.soup(text)
+        soup.foo['attr'] = 'Brawls happen at "Bob\'s Bar"'
+        self.assertSoupEquals(
+            soup.foo.decode(),
+            """a""")
+
+    def test_ampersand_in_attribute_value_gets_quoted(self):
+        self.assertSoupEquals('',
+                              '')
+
 
 class BuilderInvalidMarkupSmokeTest(SoupTest):
     """Tests of invalid markup.
 
     These are very likely to give different results for different tree
-    builders.
-
-    It's not required that a tree builder handle invalid markup at
-    all.
+    builders. It's not required that a tree builder handle invalid
+    markup at all.
     """
 
     def test_unclosed_block_level_elements(self):
@@ -82,3 +110,17 @@ class BuilderInvalidMarkupSmokeTest(SoupTest):
         self.assertSoupEquals(
             '

Foo

Bar', '

Foo

Bar

') + + def test_fake_self_closing_tag(self): + # If a self-closing tag presents as a normal tag, the 'open' + # tag is treated as an instance of the self-closing tag and + # the 'close' tag is ignored. + self.assertSoupEquals( + "http://foo.com/", + "http://foo.com/") + + def test_boolean_attribute_with_no_value_gets_empty_value(self): + soup = self.soup("
foo
") + self.assertEquals(soup.table.td['nowrap'], '') + + -- cgit v1.2.3