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.
diff --git a/Lib/test/test_ucn.py b/Lib/test/test_ucn.py
index 0797f2c..f7d3ce4 100644
--- a/Lib/test/test_ucn.py
+++ b/Lib/test/test_ucn.py
@@ -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 @@
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 @@
"""
print "done."
-
# strict error testing:
print "Testing unicode character name expansion strict error handling....",
try: