from paste.util import quoting import six import unittest class TestQuoting(unittest.TestCase): def test_html_unquote(self): self.assertEqual(quoting.html_unquote(b'<hey you>'), u'') self.assertEqual(quoting.html_unquote(b''), u'') self.assertEqual(quoting.html_unquote(b'&blahblah;'), u'&blahblah;') self.assertEqual(quoting.html_unquote(b'\xe1\x80\xa9'), u'\u1029') def test_html_quote(self): self.assertEqual(quoting.html_quote(1), '1') self.assertEqual(quoting.html_quote(None), '') self.assertEqual(quoting.html_quote(''), '<hey!>') self.assertEqual(quoting.html_quote(b''), b'<hey!>') if six.PY3: self.assertEqual(quoting.html_quote(u'<\u1029>'), u'<\u1029>') else: self.assertEqual(quoting.html_quote(u'<\u1029>'), '<\xe1\x80\xa9>')