diff options
author | Yury Selivanov <yselivanov@sprymix.com> | 2014-09-26 21:34:54 (GMT) |
---|---|---|
committer | Yury Selivanov <yselivanov@sprymix.com> | 2014-09-26 21:34:54 (GMT) |
commit | 081bbf6b28868774c1abca0a8469a517abb9f6cc (patch) | |
tree | 5a91ca676029cceeda75c4a73d2afe77696b4301 /Lib/test | |
parent | 2c0a91606105e1606d886c198ea7ed1b195c692f (diff) | |
download | cpython-081bbf6b28868774c1abca0a8469a517abb9f6cc.zip cpython-081bbf6b28868774c1abca0a8469a517abb9f6cc.tar.gz cpython-081bbf6b28868774c1abca0a8469a517abb9f6cc.tar.bz2 |
inspect: Fix getsource() to support decorated functions.
Issue #1764286. Patch by Claudiu Popa.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/inspect_fodder2.py | 13 | ||||
-rw-r--r-- | Lib/test/test_inspect.py | 3 |
2 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/inspect_fodder2.py b/Lib/test/inspect_fodder2.py index bd7106f..e452235 100644 --- a/Lib/test/inspect_fodder2.py +++ b/Lib/test/inspect_fodder2.py @@ -109,3 +109,16 @@ def annotated(arg1: list): #line 109 def keyword_only_arg(*, arg): pass + +from functools import wraps + +def decorator(func): + @wraps(func) + def fake(): + return 42 + return fake + +#line 121 +@decorator +def real(): + return 20 diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py index 6da5822..1da88c4 100644 --- a/Lib/test/test_inspect.py +++ b/Lib/test/test_inspect.py @@ -377,6 +377,9 @@ class TestDecorators(GetSourceBase): def test_replacing_decorator(self): self.assertSourceEqual(mod2.gone, 9, 10) + def test_getsource_unwrap(self): + self.assertSourceEqual(mod2.real, 122, 124) + class TestOneliners(GetSourceBase): fodderModule = mod2 def test_oneline_lambda(self): |