Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(145281)

Unified Diff: Lib/test/test_inspect.py

Issue 20691: inspect.signature: Consider exposing 'follow_wrapper_chains' option in public API
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/inspect.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/test/test_inspect.py Tue May 19 21:06:04 2015 +0200
+++ b/Lib/test/test_inspect.py Tue May 19 17:17:09 2015 -0400
@@ -1735,8 +1735,8 @@
class TestSignatureObject(unittest.TestCase):
@staticmethod
- def signature(func):
- sig = inspect.signature(func)
+ def signature(func, **kw):
+ sig = inspect.signature(func, **kw)
return (tuple((param.name,
(... if param.default is param.empty else param.default),
(... if param.annotation is param.empty
@@ -1956,6 +1956,11 @@
self.assertEqual(inspect.signature(func),
inspect.signature(decorated_func))
+ def wrapper_like(*args, **kwargs) -> int: pass
+ self.assertEqual(inspect.signature(decorated_func,
+ follow_wrapped=False),
+ inspect.signature(wrapper_like))
+
@cpython_only
def test_signature_on_builtins_no_signature(self):
import _testcapi
@@ -2384,6 +2389,13 @@
('b', ..., ..., "positional_or_keyword")),
...))
+ self.assertEqual(self.signature(Foo.bar, follow_wrapped=False),
+ ((('args', ..., ..., "var_positional"),
+ ('kwargs', ..., ..., "var_keyword")),
+ ...)) # functools.wraps will copy __annotations__
+ # from "func" to "wrapper", hence no
+ # return_annotation
+
# Test that we handle method wrappers correctly
def decorator(func):
@functools.wraps(func)
« no previous file with comments | « Lib/inspect.py ('k') | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+