diff options
author | Guido van Rossum <guido@python.org> | 2016-10-22 14:56:58 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2016-10-22 14:56:58 (GMT) |
commit | 265dce6cbbe700183228632f16bc1d4a2683c935 (patch) | |
tree | cee83144b0efb42fe0b077c25ef3c9a061a2c481 /Lib/test/test_pydoc.py | |
parent | 85e81cfe9b51ff59a2065b5863d831ee7cb72b12 (diff) | |
parent | 52e5004b59d89e5f1bf2ceaba0d2c9e63368454b (diff) | |
download | cpython-265dce6cbbe700183228632f16bc1d4a2683c935.zip cpython-265dce6cbbe700183228632f16bc1d4a2683c935.tar.gz cpython-265dce6cbbe700183228632f16bc1d4a2683c935.tar.bz2 |
Issue #27989: Tweak inspect.formatannotation() to improve pydoc rendering of function annotations. Ivan L. (3.5->3.6)
Diffstat (limited to 'Lib/test/test_pydoc.py')
-rw-r--r-- | Lib/test/test_pydoc.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_pydoc.py b/Lib/test/test_pydoc.py index 5174d56..ed438d5 100644 --- a/Lib/test/test_pydoc.py +++ b/Lib/test/test_pydoc.py @@ -15,6 +15,7 @@ import string import test.support import time import types +import typing import unittest import urllib.parse import xml.etree @@ -820,6 +821,18 @@ class TestDescriptions(unittest.TestCase): expected = 'C in module %s object' % __name__ self.assertIn(expected, pydoc.render_doc(c)) + def test_typing_pydoc(self): + def foo(data: typing.List[typing.Any], + x: int) -> typing.Iterator[typing.Tuple[int, typing.Any]]: + ... + T = typing.TypeVar('T') + class C(typing.Generic[T], typing.Mapping[int, str]): ... + self.assertEqual(pydoc.render_doc(foo).splitlines()[-1], + 'f\x08fo\x08oo\x08o(data:List[Any], x:int)' + ' -> Iterator[Tuple[int, Any]]') + self.assertEqual(pydoc.render_doc(C).splitlines()[2], + 'class C\x08C(typing.Mapping)') + def test_builtin(self): for name in ('str', 'str.translate', 'builtins.str', 'builtins.str.translate'): |