diff options
author | Yury Selivanov <yselivanov@sprymix.com> | 2014-12-08 20:00:05 (GMT) |
---|---|---|
committer | Yury Selivanov <yselivanov@sprymix.com> | 2014-12-08 20:00:05 (GMT) |
commit | b532df62b95920c380190f4a468fe15ad0c7d39c (patch) | |
tree | 7322c83d48d7c3d00c765f5330725be4dbbb6b51 /Lib/test/test_doctest.py | |
parent | a49d6a213e936bc1dcf3bbf098623e86599e59b5 (diff) | |
download | cpython-b532df62b95920c380190f4a468fe15ad0c7d39c.zip cpython-b532df62b95920c380190f4a468fe15ad0c7d39c.tar.gz cpython-b532df62b95920c380190f4a468fe15ad0c7d39c.tar.bz2 |
Issue #21740: Support wrapped callables in pydoc. Patch by Claudiu Popa.
Diffstat (limited to 'Lib/test/test_doctest.py')
-rw-r--r-- | Lib/test/test_doctest.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/Lib/test/test_doctest.py b/Lib/test/test_doctest.py index 4b8d0d2..95700a3 100644 --- a/Lib/test/test_doctest.py +++ b/Lib/test/test_doctest.py @@ -4,6 +4,7 @@ Test script for doctest. from test import support import doctest +import functools import os import sys @@ -434,7 +435,7 @@ We'll simulate a __file__ attr that ends in pyc: >>> tests = finder.find(sample_func) >>> print(tests) # doctest: +ELLIPSIS - [<DocTest sample_func from ...:18 (1 example)>] + [<DocTest sample_func from ...:19 (1 example)>] The exact name depends on how test_doctest was invoked, so allow for leading path components. @@ -2364,6 +2365,22 @@ def test_trailing_space_in_test(): foo \n """ +class Wrapper: + def __init__(self, func): + self.func = func + functools.update_wrapper(self, func) + + def __call__(self, *args, **kwargs): + self.func(*args, **kwargs) + +@Wrapper +def test_look_in_unwrapped(): + """ + Docstrings in wrapped functions must be detected as well. + + >>> 'one other test' + 'one other test' + """ def test_unittest_reportflags(): """Default unittest reporting flags can be set to control reporting |