From 431e078fbdb54adeb3875cb8c5cc75d6722de2bd Mon Sep 17 00:00:00 2001 From: Leonard Richardson Date: Tue, 7 May 2013 10:33:51 -0400 Subject: The prettify() method now leaves the contents of
 tags   alone.
 [bug=1095654]

---
 bs4/tests/test_tree.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

(limited to 'bs4/tests/test_tree.py')

diff --git a/bs4/tests/test_tree.py b/bs4/tests/test_tree.py
index 5e4a9dd..503af63 100644
--- a/bs4/tests/test_tree.py
+++ b/bs4/tests/test_tree.py
@@ -1050,7 +1050,7 @@ class TestTreeModification(SoupTest):
         # clear using decompose()
         em = a.em
         a.clear(decompose=True)
-        self.assertFalse(hasattr(em, "contents"))
+        self.assertEqual(0, len(em.contents))
 
     def test_string_set(self):
         """Tag.string = 'string'"""
@@ -1356,6 +1356,14 @@ class TestSubstitutions(SoupTest):
         encoded = soup.encode()
         self.assertTrue(b"< < hey > >" in encoded)
 
+    def test_prettify_leaves_preformatted_text_alone(self):
+        soup = self.soup("
foo
  \tbar\n  \n  
baz ") + # Everything outside the
 tag is reformatted, but everything
+        # inside is left alone.
+        self.assertEqual(
+            u'
\n foo\n
  \tbar\n  \n  
\n baz\n
', + soup.div.prettify()) + def test_prettify_accepts_formatter(self): soup = BeautifulSoup("foo") pretty = soup.prettify(formatter = lambda x: x.upper()) -- cgit v1.2.3