tiran/pysha3

Tests fail with pypy

mgorny opened this issue · 4 comments

When building with pypy, I get the following test errors:

$ python setup.py test
running test
running build
running build_py
running build_ext
test_basics (__main__.SHA3_224Tests) ... FAIL
test_hashlib (__main__.SHA3_224Tests) ... ok
test_hmac (__main__.SHA3_224Tests) ... ok
test_vectors (__main__.SHA3_224Tests) ... ok
test_vectors_unaligned (__main__.SHA3_224Tests) ... ok
test_basics (__main__.SHA3_256Tests) ... FAIL
test_hashlib (__main__.SHA3_256Tests) ... ok
test_hmac (__main__.SHA3_256Tests) ... ok
test_vectors (__main__.SHA3_256Tests) ... ok
test_vectors_unaligned (__main__.SHA3_256Tests) ... ok
test_basics (__main__.SHA3_384Tests) ... FAIL
test_hashlib (__main__.SHA3_384Tests) ... ok
test_hmac (__main__.SHA3_384Tests) ... ok
test_vectors (__main__.SHA3_384Tests) ... ok
test_vectors_unaligned (__main__.SHA3_384Tests) ... ok
test_basics (__main__.SHA3_512Tests) ... FAIL
test_hashlib (__main__.SHA3_512Tests) ... ok
test_hmac (__main__.SHA3_512Tests) ... ok
test_vectors (__main__.SHA3_512Tests) ... ok
test_vectors_unaligned (__main__.SHA3_512Tests) ... ok
test_basics (__main__.Shake_128Tests) ... FAIL
test_hashlib (__main__.Shake_128Tests) ... ok
test_hmac (__main__.Shake_128Tests) ... ok
test_vectors (__main__.Shake_128Tests) ... ok
test_vectors_unaligned (__main__.Shake_128Tests) ... ok
test_basics (__main__.Shake_256Tests) ... FAIL
test_hashlib (__main__.Shake_256Tests) ... ok
test_hmac (__main__.Shake_256Tests) ... ok
test_vectors (__main__.Shake_256Tests) ... ok
test_vectors_unaligned (__main__.Shake_256Tests) ... ok
test_basics (__main__.Keccak_224Tests) ... FAIL
test_hashlib (__main__.Keccak_224Tests) ... ok
test_hmac (__main__.Keccak_224Tests) ... ok
test_vectors (__main__.Keccak_224Tests) ... ok
test_vectors_unaligned (__main__.Keccak_224Tests) ... ok
test_basics (__main__.Keccak_256Tests) ... FAIL
test_hashlib (__main__.Keccak_256Tests) ... ok
test_hmac (__main__.Keccak_256Tests) ... ok
test_vectors (__main__.Keccak_256Tests) ... ok
test_vectors_unaligned (__main__.Keccak_256Tests) ... ok
test_basics (__main__.Keccak_384Tests) ... FAIL
test_hashlib (__main__.Keccak_384Tests) ... ok
test_hmac (__main__.Keccak_384Tests) ... ok
test_vectors (__main__.Keccak_384Tests) ... ok
test_vectors_unaligned (__main__.Keccak_384Tests) ... ok
test_basics (__main__.Keccak_512Tests) ... FAIL
test_hashlib (__main__.Keccak_512Tests) ... ok
test_hmac (__main__.Keccak_512Tests) ... ok
test_vectors (__main__.Keccak_512Tests) ... ok
test_vectors_unaligned (__main__.Keccak_512Tests) ... ok

======================================================================
FAIL: test_basics (__main__.SHA3_224Tests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests.py", line 110, in test_basics
    self.assertRaises(AttributeError, setattr, sha3, "digest", 3)
AssertionError: AttributeError not raised

======================================================================
FAIL: test_basics (__main__.SHA3_256Tests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests.py", line 110, in test_basics
    self.assertRaises(AttributeError, setattr, sha3, "digest", 3)
AssertionError: AttributeError not raised

======================================================================
FAIL: test_basics (__main__.SHA3_384Tests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests.py", line 110, in test_basics
    self.assertRaises(AttributeError, setattr, sha3, "digest", 3)
AssertionError: AttributeError not raised

======================================================================
FAIL: test_basics (__main__.SHA3_512Tests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests.py", line 110, in test_basics
    self.assertRaises(AttributeError, setattr, sha3, "digest", 3)
AssertionError: AttributeError not raised

======================================================================
FAIL: test_basics (__main__.Shake_128Tests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests.py", line 110, in test_basics
    self.assertRaises(AttributeError, setattr, sha3, "digest", 3)
AssertionError: AttributeError not raised

======================================================================
FAIL: test_basics (__main__.Shake_256Tests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests.py", line 110, in test_basics
    self.assertRaises(AttributeError, setattr, sha3, "digest", 3)
AssertionError: AttributeError not raised

======================================================================
FAIL: test_basics (__main__.Keccak_224Tests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests.py", line 110, in test_basics
    self.assertRaises(AttributeError, setattr, sha3, "digest", 3)
AssertionError: AttributeError not raised

======================================================================
FAIL: test_basics (__main__.Keccak_256Tests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests.py", line 110, in test_basics
    self.assertRaises(AttributeError, setattr, sha3, "digest", 3)
AssertionError: AttributeError not raised

======================================================================
FAIL: test_basics (__main__.Keccak_384Tests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests.py", line 110, in test_basics
    self.assertRaises(AttributeError, setattr, sha3, "digest", 3)
AssertionError: AttributeError not raised

======================================================================
FAIL: test_basics (__main__.Keccak_512Tests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests.py", line 110, in test_basics
    self.assertRaises(AttributeError, setattr, sha3, "digest", 3)
AssertionError: AttributeError not raised

----------------------------------------------------------------------
Ran 50 tests in 2.348s

FAILED (failures=10)
Traceback (most recent call last):
  File "setup.py", line 123, in <module>
    "Topic :: Security :: Cryptography",
  File "/usr/lib64/pypy/lib-python/2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/usr/lib64/pypy/lib-python/2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/usr/lib64/pypy/lib-python/2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "setup.py", line 64, in run
    errno = subprocess.check_call([sys.executable, "tests.py"], env=env)
  File "/usr/lib64/pypy/lib-python/2.7/subprocess.py", line 186, in check_call
    raise CalledProcessError(retcode, cmd)
CalledProcessError: Command '['/tmp/pysha3-1.0.2/_venv/bin/python', 'tests.py']' returned non-zero exit status 1
tiran commented

It looks like a bug in PyPy. You shouldn't be able to modify any members like methods or attributes.

It's about the stuff originating from the C extension module, correct? Is there any chance you'd be interested in reporting the issue to PyPy upstream? I think you would be able to explain it better than I do.

tiran commented

pysha3 is no longer supported. Please use SHA-3 from Python's hashlib module.