mirror of
https://github.com/python/cpython.git
synced 2025-08-27 04:05:34 +00:00
added "getcode" and "getname" methods to the ucnhash module (they're
probably more useful for the test code than for any applications, but one never knows...)
This commit is contained in:
parent
d5d2cd149f
commit
ee865c64da
2 changed files with 75 additions and 13 deletions
|
@ -37,6 +37,23 @@ s = u"\N{LATIN CAPITAL LETTER T}" \
|
|||
u"\N{LATIN SMALL LETTER P}" \
|
||||
u"\N{FULL STOP}"
|
||||
verify(s == u"The rEd fOx ate the sheep.", s)
|
||||
|
||||
import ucnhash
|
||||
|
||||
# minimal sanity check
|
||||
for char in "SPAM":
|
||||
name = "LATIN SMALL LETTER %s" % char
|
||||
code = ucnhash.getcode(name)
|
||||
verify(ucnhash.getname(code) == name)
|
||||
|
||||
# loop over all characters in the database
|
||||
for code in range(65536):
|
||||
try:
|
||||
name = ucnhash.getname(code)
|
||||
verify(ucnhash.getcode(name) == code)
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
print "done."
|
||||
|
||||
# misc. symbol testing
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue