diff options
author | Dan Rose <rotu@users.noreply.github.com> | 2019-05-24 11:38:01 (GMT) |
---|---|---|
committer | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-05-24 11:38:01 (GMT) |
commit | 2a37f8f55b543589cc77a67b5cd17cbd9d0311c9 (patch) | |
tree | 7bf4242f52dd92ffb0c8a731fe7d2e0f1864556e /Lib/test/test_pydoc.py | |
parent | cf7d5ef49b1d28f35af137d23ec1a94f3eae090d (diff) | |
download | cpython-2a37f8f55b543589cc77a67b5cd17cbd9d0311c9.zip cpython-2a37f8f55b543589cc77a67b5cd17cbd9d0311c9.tar.gz cpython-2a37f8f55b543589cc77a67b5cd17cbd9d0311c9.tar.bz2 |
bpo-36045: builtins.help() now prefixes `async` for async functions (GH-12010)
Previously, it was hard to tell whether a function should be awaited. It was also incorrect (per PEP 484) to put this in the type hint for coroutine functions. Added this info to the output of builtins.help and pydoc.
https://bugs.python.org/issue36045
Diffstat (limited to 'Lib/test/test_pydoc.py')
-rw-r--r-- | Lib/test/test_pydoc.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/test/test_pydoc.py b/Lib/test/test_pydoc.py index 67c6c5d..6efdeb0 100644 --- a/Lib/test/test_pydoc.py +++ b/Lib/test/test_pydoc.py @@ -1288,6 +1288,29 @@ foo Custom descriptor """) + def test_async_annotation(self): + async def coro_function(ign) -> int: + return 1 + + text = pydoc.plain(pydoc.plaintext.document(coro_function)) + self.assertIn('async coro_function', text) + + html = pydoc.HTMLDoc().document(coro_function) + self.assertIn( + 'async <a name="-coro_function"><strong>coro_function', + html) + + def test_async_generator_annotation(self): + async def an_async_generator(): + yield 1 + + text = pydoc.plain(pydoc.plaintext.document(an_async_generator)) + self.assertIn('async an_async_generator', text) + + html = pydoc.HTMLDoc().document(an_async_generator) + self.assertIn( + 'async <a name="-an_async_generator"><strong>an_async_generator', + html) class PydocServerTest(unittest.TestCase): """Tests for pydoc._start_server""" |