diff Lib/test/test_codeccallbacks.py @ 28892:35c90d9cc313 legacy-trunk

Use the new htmlentitydefs.codepoint2name for test_xmlcharnamereplace()
author Walter Dörwald <walter@livinglogic.de>
date Tue, 29 Apr 2003 20:59:55 +0000
parents 226463445697
children 1741af48fd9f
line wrap: on
line diff
--- a/Lib/test/test_codeccallbacks.py	Tue Apr 29 19:58:04 2003 +0000
+++ b/Lib/test/test_codeccallbacks.py	Tue Apr 29 20:59:55 2003 +0000
@@ -37,12 +37,6 @@
     def test_xmlcharnamereplace(self):
         # This time use a named character entity for unencodable
         # characters, if one is available.
-        names = {}
-        for (key, value) in htmlentitydefs.entitydefs.items():
-            if len(value)==1:
-                names[unicode(value, "latin-1")] = unicode(key, "latin-1")
-            else:
-                names[unichr(int(value[2:-1]))] = unicode(key, "latin-1")
 
         def xmlcharnamereplace(exc):
             if not isinstance(exc, UnicodeEncodeError):
@@ -50,7 +44,7 @@
             l = []
             for c in exc.object[exc.start:exc.end]:
                 try:
-                    l.append(u"&%s;" % names[c])
+                    l.append(u"&%s;" % htmlentitydefs.codepoint2name[ord(c)])
                 except KeyError:
                     l.append(u"&#%d;" % ord(c))
             return (u"".join(l), exc.end)