Skip to content
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.

Commit

Permalink
Add tests that _escape_cdata and _escape_attrib handle UnicodeError. C…
Browse files Browse the repository at this point in the history
…loses #5
  • Loading branch information
mnaberez committed Nov 28, 2012
1 parent 0738881 commit df96b6b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions meld3/test_meld3.py
Original file line number Diff line number Diff line change
Expand Up @@ -1746,11 +1746,21 @@ def test_escape_cdata(self):
from meld3 import _escape_cdata
self.assertEqual('< > <& &' && &foo "" http://www.plope.com?foo=bar&bang=baz {', _escape_cdata(a))

def test_escape_cdata_unicodeerror(self):
a = eval(r'u"\u0080"')
from meld3 import _escape_cdata
self.assertEqual('€', _escape_cdata(a, 'ascii'))

def test_escape_attrib(self):
a = '< > &lt;&amp; &&apos; && &foo "" http://www.plope.com?foo=bar&bang=baz &#123;'
from meld3 import _escape_attrib
self.assertEqual('&lt; > &lt;&amp; &amp;&apos; &amp;&amp; &amp;foo &quot;&quot; http://www.plope.com?foo=bar&amp;bang=baz &#123;', _escape_attrib(a))

def test_escape_attrib_unicodeerror(self):
a = eval(r'u"\u0080"')
from meld3 import _escape_attrib
self.assertEqual('&#128;', _escape_attrib(a, 'ascii'))

def normalize_html(s):
s = re.sub(r"[ \t]+", " ", s)
s = re.sub(r"/>", ">", s)
Expand Down

0 comments on commit df96b6b

Please sign in to comment.