testing-cabal / funcsigs

Python function signatures package for Python 2.6, 2.7 and 3.3+
http://pypi.python.org/pypi/funcsigs
Other
8 stars 13 forks source link

multiple test failures in version 0.4 with pypy3 #10

Open rbtcollins opened 8 years ago

rbtcollins commented 8 years ago
======================================================================
ERROR: test_signature_on_callable_objects (tests.test_inspect.TestSignatureObject)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/var/tmp/portage/dev-python/funcsigs-0.4/work/funcsigs-0.4/tests/test_inspect.py", line 508, in test_signature_on_callable_objects
    self.assertEqual(self.signature(Foo()),
  File "/var/tmp/portage/dev-python/funcsigs-0.4/work/funcsigs-0.4/tests/test_inspect.py", line 17, in signature
    sig = inspect.signature(func)
  File "/var/tmp/portage/dev-python/funcsigs-0.4/work/funcsigs-0.4/funcsigs/__init__.py", line 176, in signature
    raise ValueError('callable {0!r} is not supported by signature'.format(obj))
ValueError: callable <tests.test_inspect.Foo object at 0x0000000001405948> is not supported by signature

======================================================================
ERROR: test_signature_on_class (tests.test_inspect.TestSignatureObject)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "<string>", line 7, in test_signature_on_class
  File "/var/tmp/portage/dev-python/funcsigs-0.4/work/funcsigs-0.4/tests/test_inspect.py", line 17, in signature
    sig = inspect.signature(func)
  File "/var/tmp/portage/dev-python/funcsigs-0.4/work/funcsigs-0.4/funcsigs/__init__.py", line 176, in signature
    raise ValueError('callable {0!r} is not supported by signature'.format(obj))
ValueError: callable <class 'tests.test_inspect.C'> is not supported by signature

----------------------------------------------------------------------

From aliles/funcsigs#18, filed by @jlec

MathyV commented 7 years ago

I was looking into why this is occurring and possible create a fix, but I got stuck for the moment. It seems that the behaviour for _get_user_defined_method is different for the different implementations, but my python voodoo isn't strong enough to come up with a solution atm. I'm checking with the pypy devs why the behaviour is different.

This is the simplified testcase:

import types

class Foo(object):
    def __call__(self, a):
        pass

meth = getattr(Foo, "__call__")

w = type(type.__call__)
m = type(all.__call__)

n = (w, m, types.BuiltinFunctionType)

print(isinstance(meth, w))
print(isinstance(meth, m))
print(isinstance(meth, types.BuiltinFunctionType))

print(isinstance(meth, n))

Output:

$ pypy  test-pypy3.py
True
True
False
True
$ python2.7 test-pypy3.py
False
False
False
False
$ pypy3  test-pypy3.py
True
False
False
True
$ python3 test-pypy3.py
False
False
False
False
MathyV commented 7 years ago

I checked on #pypy where I was pointed to this page which mentions differences in the inspect module:

http://doc.pypy.org/en/latest/cpython_differences.html#miscellaneous

MathyV commented 7 years ago

BTW: the reason it works on pypy is because the failing tests are being ignored by the sys.version_info[0] > 2 check.