[pypy-svn] r58964 - in pypy/dist/pypy/module/unicodedata: . test
cfbolz at codespeak.net
cfbolz at codespeak.net
Sat Oct 11 13:28:26 CEST 2008
Author: cfbolz
Date: Sat Oct 11 13:28:25 2008
New Revision: 58964
Modified:
pypy/dist/pypy/module/unicodedata/__init__.py
pypy/dist/pypy/module/unicodedata/interp_ucd.py
pypy/dist/pypy/module/unicodedata/test/test_unicodedata.py
Log:
(iko, cfbolz): Use the same unicode-database that CPython 2.5 uses. Write a test
that checks some stuff from the unicode database against the underlying
Python's.
Modified: pypy/dist/pypy/module/unicodedata/__init__.py
==============================================================================
--- pypy/dist/pypy/module/unicodedata/__init__.py (original)
+++ pypy/dist/pypy/module/unicodedata/__init__.py Sat Oct 11 13:28:25 2008
@@ -6,7 +6,7 @@
interpleveldefs = {
'unidata_version' : 'space.wrap(interp_ucd.ucd.version)',
'ucd_3_2_0' : 'space.wrap(interp_ucd.ucd_3_2_0)',
- #'ucd_4_1_0' : 'space.wrap(interp_ucd.ucd_4_1_0)',
+ 'ucd_4_1_0' : 'space.wrap(interp_ucd.ucd_4_1_0)',
#'ucd_5_0_0' : 'space.wrap(interp_ucd.ucd_5_0_0)',
'ucd' : 'space.wrap(interp_ucd.ucd)',
'__doc__' : "space.wrap('unicode character database')",
Modified: pypy/dist/pypy/module/unicodedata/interp_ucd.py
==============================================================================
--- pypy/dist/pypy/module/unicodedata/interp_ucd.py (original)
+++ pypy/dist/pypy/module/unicodedata/interp_ucd.py Sat Oct 11 13:28:25 2008
@@ -289,5 +289,5 @@
ucd_3_2_0 = UCD(unicodedb_3_2_0)
ucd_4_1_0 = UCD(unicodedb_4_1_0)
ucd_5_0_0 = UCD(unicodedb_5_0_0)
-ucd = ucd_3_2_0
+ucd = ucd_4_1_0
Modified: pypy/dist/pypy/module/unicodedata/test/test_unicodedata.py
==============================================================================
--- pypy/dist/pypy/module/unicodedata/test/test_unicodedata.py (original)
+++ pypy/dist/pypy/module/unicodedata/test/test_unicodedata.py Sat Oct 11 13:28:25 2008
@@ -3,8 +3,24 @@
class AppTestUnicodeData:
def setup_class(cls):
+ import random, unicodedata
+ seed = random.getrandbits(32)
+ print "random seed: ", seed
+ random.seed(seed)
space = gettestobjspace(usemodules=('unicodedata',))
cls.space = space
+ charlist_w = []
+ for i in range(2000):
+ chr = unichr(random.randrange(65536))
+ try:
+ w_tup = space.newtuple([
+ space.wrap(chr),
+ space.wrap(unicodedata.name(chr))
+ ])
+ charlist_w.append(w_tup)
+ except ValueError:
+ pass
+ cls.w_charlist = space.newlist(charlist_w)
def test_hangul_syllables(self):
import unicodedata
@@ -70,3 +86,10 @@
except ValueError:
pass
raises(KeyError, unicodedata.lookup, charname)
+
+ def test_random_charnames(self):
+ import unicodedata
+ for chr, name in self.charlist:
+ assert unicodedata.name(chr) == name
+ assert unicodedata.lookup(name) == chr
+
More information about the Pypy-commit
mailing list