[pypy-svn] r79709 - pypy/trunk/lib_pypy/pypy_test
arigo at codespeak.net
arigo at codespeak.net
Wed Dec 1 14:34:04 CET 2010
Author: arigo
Date: Wed Dec 1 14:34:03 2010
New Revision: 79709
Modified:
pypy/trunk/lib_pypy/pypy_test/test_hashlib.py
Log:
Fix test.
Modified: pypy/trunk/lib_pypy/pypy_test/test_hashlib.py
==============================================================================
--- pypy/trunk/lib_pypy/pypy_test/test_hashlib.py (original)
+++ pypy/trunk/lib_pypy/pypy_test/test_hashlib.py Wed Dec 1 14:34:03 2010
@@ -8,6 +8,15 @@
def test_unicode():
assert isinstance(hashlib.new('sha256', u'xxx'), _hashlib.hash)
+pure_python_version = {
+ 'md5': 'md5.new',
+ 'sha1': 'sha.new',
+ 'sha224': '_sha256.sha224',
+ 'sha256': '_sha256.sha256',
+ 'sha384': '_sha512.sha384',
+ 'sha512': '_sha512.sha512',
+ }
+
def test_attributes():
for name, expected_size in {'md5': 16,
'sha1': 20,
@@ -31,7 +40,9 @@
assert hexdigest == h.hexdigest()
# also test the pure Python implementation
- h = hashlib.__get_builtin_constructor(name)('')
+ modname, constructor = pure_python_version[name].split('.')
+ builder = getattr(__import__(modname), constructor)
+ h = builder('')
assert h.digest_size == expected_size
assert h.digestsize == expected_size
#
More information about the Pypy-commit
mailing list