[Python-checkins] bpo-32650: Add an asyncgen pdb test (GH-5406) (#5419)
Andrew Svetlov
webhook-mailer at python.org
Mon Jan 29 05:41:37 EST 2018
https://github.com/python/cpython/commit/d9c743b2d118530ca13a8e29f96f30950866bd56
commit: d9c743b2d118530ca13a8e29f96f30950866bd56
branch: 3.6
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: Andrew Svetlov <andrew.svetlov at gmail.com>
date: 2018-01-29T12:41:34+02:00
summary:
bpo-32650: Add an asyncgen pdb test (GH-5406) (#5419)
(cherry picked from commit 9ee1bf9ab5af8233ed8ec5c53d12a29dc1bd9c9d)
files:
M Lib/test/test_pdb.py
diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py
index 6d7e149805cb..369a0a91e305 100644
--- a/Lib/test/test_pdb.py
+++ b/Lib/test/test_pdb.py
@@ -779,6 +779,66 @@ def test_pdb_next_command_for_coroutine():
finished
"""
+def test_pdb_next_command_for_asyncgen():
+ """Testing skip unwindng stack on yield for coroutines for "next" command
+
+ >>> import asyncio
+
+ >>> async def agen():
+ ... yield 1
+ ... await asyncio.sleep(0)
+ ... yield 2
+
+ >>> async def test_coro():
+ ... async for x in agen():
+ ... print(x)
+
+ >>> async def test_main():
+ ... import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace()
+ ... await test_coro()
+
+ >>> def test_function():
+ ... loop = asyncio.new_event_loop()
+ ... loop.run_until_complete(test_main())
+ ... loop.close()
+ ... print("finished")
+
+ >>> with PdbTestInput(['step',
+ ... 'step',
+ ... 'next',
+ ... 'next',
+ ... 'step',
+ ... 'next',
+ ... 'continue']):
+ ... test_function()
+ > <doctest test.test_pdb.test_pdb_next_command_for_asyncgen[3]>(3)test_main()
+ -> await test_coro()
+ (Pdb) step
+ --Call--
+ > <doctest test.test_pdb.test_pdb_next_command_for_asyncgen[2]>(1)test_coro()
+ -> async def test_coro():
+ (Pdb) step
+ > <doctest test.test_pdb.test_pdb_next_command_for_asyncgen[2]>(2)test_coro()
+ -> async for x in agen():
+ (Pdb) next
+ > <doctest test.test_pdb.test_pdb_next_command_for_asyncgen[2]>(3)test_coro()
+ -> print(x)
+ (Pdb) next
+ 1
+ > <doctest test.test_pdb.test_pdb_next_command_for_asyncgen[2]>(2)test_coro()
+ -> async for x in agen():
+ (Pdb) step
+ --Call--
+ > <doctest test.test_pdb.test_pdb_next_command_for_asyncgen[1]>(2)agen()
+ -> yield 1
+ (Pdb) next
+ > <doctest test.test_pdb.test_pdb_next_command_for_asyncgen[1]>(3)agen()
+ -> await asyncio.sleep(0)
+ (Pdb) continue
+ 2
+ finished
+ """
+
def test_pdb_return_command_for_generator():
"""Testing no unwindng stack on yield for generators
for "return" command
More information about the Python-checkins
mailing list