Source

WebHelpers / tests / test_escapes.py

from nose.tools import eq_
from webhelpers.util import *

def test_html_escape():
    eq_(html_escape('foo'), 'foo')
    eq_(html_escape('<this"that>'), '&lt;this&quot;that&gt;')
    eq_(html_escape('\u1000'), '&#4096;')
    class X:
        def __str__(self):
            return '<\u1000>'
    eq_(html_escape(X()), '&lt;&#4096;&gt;')
    eq_(html_escape(1), '1')
    eq_(html_escape(None), '')