Move uchhash functionality into unicodedata (after the recent

crop of changes, the files are small enough to do this).  Also
adds "name" and "lookup" functions to unicodedata.
This commit is contained in:
Fredrik Lundh 2001-01-24 07:59:11 +00:00
parent eda28445c0
commit 06d126803c
4 changed files with 248 additions and 228 deletions

View file

@ -1,6 +1,7 @@
""" Test script for the Unicode implementation.
Written by Bill Tutt.
Modified for Python 2.0 by Fredrik Lundh (fredrik@pythonware.com)
(c) Copyright CNRI, All Rights Reserved. NO WARRANTY.
@ -46,23 +47,24 @@ except UnicodeError, v:
print v
print "done."
import ucnhash
import unicodedata
print "Testing name to code mapping....",
for char in "SPAM":
name = "LATIN SMALL LETTER %s" % char
code = ucnhash.getcode(name)
verify(ucnhash.getname(code) == name)
code = unicodedata.lookup(name)
verify(unicodedata.name(code) == name)
print "done."
print "Testing code to name mapping for all characters....",
count = 0
for code in range(65536):
try:
name = ucnhash.getname(code)
verify(ucnhash.getcode(name) == code)
char = unichr(code)
name = unicodedata.name(char)
verify(unicodedata.lookup(name) == char)
count += 1
except ValueError:
except (KeyError, ValueError):
pass
print "done."
@ -78,7 +80,6 @@ verify(u"\N{FULLWIDTH LATIN SMALL LETTER A}" == u"\uFF41")
"""
print "done."
# strict error testing:
print "Testing unicode character name expansion strict error handling....",
try: