File: test_quoting.py

package info (click to toggle)
paste 2.0.3%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,396 kB
  • ctags: 2,615
  • sloc: python: 18,659; makefile: 17; sh: 7
file content (28 lines) | stat: -rw-r--r-- 1,073 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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'<hey\xa0you>')
        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!>'),
                         '&lt;hey!&gt;')
        if six.PY3:
            self.assertEqual(quoting.html_quote(u'<\u1029>'),
                             u'&lt;\u1029&gt;')
        else:
            self.assertEqual(quoting.html_quote(u'<\u1029>'),
                             '&lt;\xe1\x80\xa9&gt;')