summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2016-10-22 14:55:18 (GMT)
committerGuido van Rossum <guido@python.org>2016-10-22 14:55:18 (GMT)
commit52e5004b59d89e5f1bf2ceaba0d2c9e63368454b (patch)
treeca181df1676c03561a69d34285b4d9b1d0a0d525 /Lib/test
parent1002a621c1f0c8d5adcdd6462b9bdd0470e34290 (diff)
downloadcpython-52e5004b59d89e5f1bf2ceaba0d2c9e63368454b.zip
cpython-52e5004b59d89e5f1bf2ceaba0d2c9e63368454b.tar.gz
cpython-52e5004b59d89e5f1bf2ceaba0d2c9e63368454b.tar.bz2
Issue #27989: Tweak inspect.formatannotation() to improve pydoc rendering of function annotations. Ivan L.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_pydoc.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_pydoc.py b/Lib/test/test_pydoc.py
index aee979b..1f7ab7f 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
@@ -815,6 +816,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'):