summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorFredrik Lundh <fredrik@pythonware.com>2001-01-24 07:59:11 (GMT)
committerFredrik Lundh <fredrik@pythonware.com>2001-01-24 07:59:11 (GMT)
commit06d126803c66515f5cdb272dfd7807716f04d33f (patch)
tree1f1bb52eee3fbb613c83eae4bb0c8b82ea276257 /Lib/test
parenteda28445c075102690710e3775b7f419669eb653 (diff)
downloadcpython-06d126803c66515f5cdb272dfd7807716f04d33f.zip
cpython-06d126803c66515f5cdb272dfd7807716f04d33f.tar.gz
cpython-06d126803c66515f5cdb272dfd7807716f04d33f.tar.bz2
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.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_ucn.py15
1 files changed, 8 insertions, 7 deletions
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 @@ 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: