[pypy-svn] r64355 - in pypy/trunk/pypy/module/md5: . test

arigo at codespeak.net arigo at codespeak.net
Sun Apr 19 13:15:56 CEST 2009


Author: arigo
Date: Sun Apr 19 13:15:55 2009
New Revision: 64355

Modified:
   pypy/trunk/pypy/module/md5/__init__.py
   pypy/trunk/pypy/module/md5/interp_md5.py
   pypy/trunk/pypy/module/md5/test/test_md5.py
Log:
Add blocksize and digestsize as needed.


Modified: pypy/trunk/pypy/module/md5/__init__.py
==============================================================================
--- pypy/trunk/pypy/module/md5/__init__.py	(original)
+++ pypy/trunk/pypy/module/md5/__init__.py	Sun Apr 19 13:15:55 2009
@@ -23,6 +23,8 @@
         'new': 'interp_md5.W_MD5',
         'MD5Type': 'interp_md5.W_MD5',
         'digest_size': 'space.wrap(16)',
+        'digestsize': 'space.wrap(16)',
+        'blocksize': 'space.wrap(1)',
         }
 
     appleveldefs = {

Modified: pypy/trunk/pypy/module/md5/interp_md5.py
==============================================================================
--- pypy/trunk/pypy/module/md5/interp_md5.py	(original)
+++ pypy/trunk/pypy/module/md5/interp_md5.py	Sun Apr 19 13:15:55 2009
@@ -47,6 +47,8 @@
     digest    = interp2app(W_MD5.digest_w, unwrap_spec=['self']),
     hexdigest = interp2app(W_MD5.hexdigest_w, unwrap_spec=['self']),
     copy      = interp2app(W_MD5.copy_w, unwrap_spec=['self']),
+    digest_size = 16,
+    digestsize = 16,
     __doc__   = """md5(arg) -> return new md5 object.
 
 If arg is present, the method call update(arg) is made.""")

Modified: pypy/trunk/pypy/module/md5/test/test_md5.py
==============================================================================
--- pypy/trunk/pypy/module/md5/test/test_md5.py	(original)
+++ pypy/trunk/pypy/module/md5/test/test_md5.py	Sun Apr 19 13:15:55 2009
@@ -2,7 +2,7 @@
 Tests for the md5 module implemented at interp-level in pypy/module/md5.
 """
 
-import py
+import py, sys
 from pypy.conftest import gettestobjspace
 
 
@@ -25,6 +25,11 @@
         md5.digest_size should be 16.
         """
         assert self.md5.digest_size == 16
+        #assert self.md5.digestsize == 16        -- not on CPython
+        assert self.md5.md5().digest_size == 16
+        if sys.version >= (2, 5):
+            assert self.md5.blocksize == 1
+            assert self.md5.md5().digestsize == 16
 
 
     def test_MD5Type(self):
@@ -33,9 +38,11 @@
         """
         md5 = self.md5
         d = md5.md5()
-        assert isinstance(d, md5.MD5Type)
+        if hasattr(md5, 'MD5Type'):    # not on CPython 2.5
+            assert isinstance(d, md5.MD5Type)
         d = md5.new()
-        assert isinstance(d, md5.MD5Type)
+        if hasattr(md5, 'MD5Type'):    # not on CPython 2.5
+            assert isinstance(d, md5.MD5Type)
 
 
     def test_md5object(self):



More information about the Pypy-commit mailing list