summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_inspect.py
diff options
context:
space:
mode:
authorYury Selivanov <yselivanov@sprymix.com>2014-02-21 23:30:53 (GMT)
committerYury Selivanov <yselivanov@sprymix.com>2014-02-21 23:30:53 (GMT)
commita773de040d6273588911e6f67e78f45819850b4d (patch)
tree10b6d5bc93919b8ba8bf9bdd27a298cea09c33d8 /Lib/test/test_inspect.py
parent8c8b4e0ebf5f58fae2d10453cda9d4ee614794d9 (diff)
downloadcpython-a773de040d6273588911e6f67e78f45819850b4d.zip
cpython-a773de040d6273588911e6f67e78f45819850b4d.tar.gz
cpython-a773de040d6273588911e6f67e78f45819850b4d.tar.bz2
inspect.signature: Check for function-like objects before builtins. Issue #17159
Diffstat (limited to 'Lib/test/test_inspect.py')
-rw-r--r--Lib/test/test_inspect.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
index 95c1b32..0dc7451 100644
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -14,6 +14,7 @@ import sys
import types
import unicodedata
import unittest
+import unittest.mock
try:
from concurrent.futures import ThreadPoolExecutor
@@ -1836,6 +1837,21 @@ class TestSignatureObject(unittest.TestCase):
('kwargs', ..., ..., "var_keyword")),
...))
+ # Test with cython-like builtins:
+ _orig_isdesc = inspect.ismethoddescriptor
+ def _isdesc(obj):
+ if hasattr(obj, '_builtinmock'):
+ return True
+ return _orig_isdesc(obj)
+
+ with unittest.mock.patch('inspect.ismethoddescriptor', _isdesc):
+ builtin_func = funclike(func)
+ # Make sure that our mock setup is working
+ self.assertFalse(inspect.ismethoddescriptor(builtin_func))
+ builtin_func._builtinmock = True
+ self.assertTrue(inspect.ismethoddescriptor(builtin_func))
+ self.assertEqual(inspect.signature(builtin_func), sig_func)
+
def test_signature_functionlike_class(self):
# We only want to duck type function-like objects,
# not classes.