From 0ce55d794c2ed142f70674d2b48e8294ca8b1d22 Mon Sep 17 00:00:00 2001 From: Leonard Richardson Date: Thu, 25 Jun 2015 07:35:32 -0400 Subject: __repr__ now returns an ASCII bytestring in Python 2, and a Unicode string in Python 3, instead of a UTF8-encoded bytestring in both versions. [bug=1420131] --- bs4/tests/test_tree.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'bs4/tests') diff --git a/bs4/tests/test_tree.py b/bs4/tests/test_tree.py index 7c44c48..bab73c6 100644 --- a/bs4/tests/test_tree.py +++ b/bs4/tests/test_tree.py @@ -19,6 +19,7 @@ from bs4.builder import ( HTMLParserTreeBuilder, ) from bs4.element import ( + PY3K, CData, Comment, Doctype, @@ -1490,6 +1491,14 @@ class TestEncoding(SoupTest): self.assertEqual( u"\N{SNOWMAN}".encode("utf8"), soup.b.renderContents()) + def test_repr(self): + html = u"\N{SNOWMAN}" + soup = self.soup(html) + if PY3K: + self.assertEqual(html, repr(soup)) + else: + self.assertEqual(b'\\u2603', repr(soup)) + class TestNavigableStringSubclasses(SoupTest): def test_cdata(self): -- cgit v1.2.3