summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_inspect.py
diff options
context:
space:
mode:
authorYury Selivanov <yselivanov@sprymix.com>2014-02-19 21:27:23 (GMT)
committerYury Selivanov <yselivanov@sprymix.com>2014-02-19 21:27:23 (GMT)
commit57d240ef645c4d78432ce722844c150e5ba25fbb (patch)
treea656f202253735833a58a91b2ee7ed732d947cc2 /Lib/test/test_inspect.py
parent4ac30f17925bc5dc283cd638a43b9ecde95b63a9 (diff)
downloadcpython-57d240ef645c4d78432ce722844c150e5ba25fbb.zip
cpython-57d240ef645c4d78432ce722844c150e5ba25fbb.tar.gz
cpython-57d240ef645c4d78432ce722844c150e5ba25fbb.tar.bz2
inspect: Fix getfullargspec() to not to follow __wrapped__ chains
Initial patch by Nick Coghlan.
Diffstat (limited to 'Lib/test/test_inspect.py')
-rw-r--r--Lib/test/test_inspect.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
index a34a418..711d2a3 100644
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -577,6 +577,46 @@ class TestClassesAndFunctions(unittest.TestCase):
kwonlyargs_e=['arg'],
formatted='(*, arg)')
+ def test_argspec_api_ignores_wrapped(self):
+ # Issue 20684: low level introspection API must ignore __wrapped__
+ @functools.wraps(mod.spam)
+ def ham(x, y):
+ pass
+ # Basic check
+ self.assertArgSpecEquals(ham, ['x', 'y'], formatted='(x, y)')
+ self.assertFullArgSpecEquals(ham, ['x', 'y'], formatted='(x, y)')
+ self.assertFullArgSpecEquals(functools.partial(ham),
+ ['x', 'y'], formatted='(x, y)')
+ # Other variants
+ def check_method(f):
+ self.assertArgSpecEquals(f, ['self', 'x', 'y'],
+ formatted='(self, x, y)')
+ class C:
+ @functools.wraps(mod.spam)
+ def ham(self, x, y):
+ pass
+ pham = functools.partialmethod(ham)
+ @functools.wraps(mod.spam)
+ def __call__(self, x, y):
+ pass
+ check_method(C())
+ check_method(C.ham)
+ check_method(C().ham)
+ check_method(C.pham)
+ check_method(C().pham)
+
+ class C_new:
+ @functools.wraps(mod.spam)
+ def __new__(self, x, y):
+ pass
+ check_method(C_new)
+
+ class C_init:
+ @functools.wraps(mod.spam)
+ def __init__(self, x, y):
+ pass
+ check_method(C_init)
+
def test_getfullargspec_signature_attr(self):
def test():
pass