summaryrefslogtreecommitdiff
path: root/tests/test_tree.py
diff options
context:
space:
mode:
authorLeonard Richardson <leonard.richardson@canonical.com>2011-02-10 09:47:47 -0500
committerLeonard Richardson <leonard.richardson@canonical.com>2011-02-10 09:47:47 -0500
commit0dcb2c0eca6c348718ff29a0747ca605316610a8 (patch)
treeb32a00135d73bc9034f1270208f6cdbce2ca584b /tests/test_tree.py
parent3366ad67dc2dfdd508267efc87dfc851b612fb0d (diff)
Fixed the ability to encode strings.
Diffstat (limited to 'tests/test_tree.py')
-rw-r--r--tests/test_tree.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/test_tree.py b/tests/test_tree.py
index eac4e72..ed29d76 100644
--- a/tests/test_tree.py
+++ b/tests/test_tree.py
@@ -815,3 +815,19 @@ class TestPersistence(SoupTest):
dumped = pickle.dumps(soup, pickle.HIGHEST_PROTOCOL)
loaded = pickle.loads(dumped)
self.assertEqual(loaded.decode(), soup.decode())
+
+
+class TestEncoding(SoupTest):
+ """Test the ability to encode strings."""
+
+ def test_unicode_string_can_be_encoded(self):
+ html = u"<b>\N{SNOWMAN}</b>"
+ soup = self.soup(html)
+ self.assertEquals(soup.b.string.encode("utf-8"),
+ u"\N{SNOWMAN}".encode("utf-8"))
+
+ def test_tag_containing_unicode_string_can_be_encoded(self):
+ html = u"<b>\N{SNOWMAN}</b>"
+ soup = self.soup(html)
+ self.assertEquals(soup.b.encode("utf-8"),
+ html.encode("utf-8"))