Commits

Amaury Forgeot d'Arc committed 8c04163

Try to fix tests

Comments (0)

Files changed (3)

 
 digest_size = 16
 
-def md5(arg=None):
-    """Same as new().
-
-    For backward compatibility reasons, this is an alternative
-    name for the new() function.
+def new(arg=None):
+    """Return a new md5 crypto object.
+    If arg is present, the method call update(arg) is made.
     """
 
-    return new(arg)
+    crypto = MD5Type()
+    if arg:
+        crypto.update(arg)
+
+    return crypto
+

lib_pypy/pypy_test/test_md5_extra.py

     d1h = m1.hexdigest()
     
     # Use MD5 module in pure Python.
-    m2 = pymd5.md5()
+    m2 = pymd5.new()
     m2.update(message)
     d2 = m2.digest()
     d2h = m2.hexdigest()
         m1.update(prefix1)
         m1c = m1.copy()
 
-        m2 = pymd5.md5()
+        m2 = pymd5.new()
         m2.update(prefix1)
         m2c = m2.copy()
 
 
 def test_attributes():
     assert pymd5.digest_size == 16
-    assert pymd5.digestsize == 16
-    assert pymd5.blocksize == 1
-    assert pymd5.md5().digest_size == 16
-    assert pymd5.md5().digestsize == 16
+    assert pymd5.new().digest_size == 16
+    assert pymd5.new().digestsize == 16
+    assert pymd5.new().block_size == 64

lib_pypy/pypy_test/test_sha_extra.py

 # Publication 180-1, Secure Hash Standard,  1995 April 17
 # http://www.itl.nist.gov/div897/pubs/fip180-1.htm
 from __future__ import absolute_import
-from .. import _sha 
+from .. import _sha as pysha
 
 class TestSHA: 
     def check(self, data, digest):
-        computed = sha.new(data).hexdigest()
+        computed = pysha.new(data).hexdigest()
         assert computed == digest
 
     def test_case_1(self):
 
 
 def test_attributes():
-    assert sha.digest_size == 20
-    assert sha.digestsize == 20
-    assert sha.blocksize == 1
-    assert sha.sha().digest_size == 20
-    assert sha.sha().digestsize == 20
+    assert pysha.digest_size == 20
+    assert pysha.digestsize == 20
+    assert pysha.blocksize == 1
+    assert pysha.new().digest_size == 20
+    assert pysha.new().digestsize == 20