Skip to content

Commit d9c743b

Browse files
miss-islingtonasvetlov
authored andcommitted
bpo-32650: Add an asyncgen pdb test (GH-5406) (#5419)
(cherry picked from commit 9ee1bf9)
1 parent 190de18 commit d9c743b

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

Lib/test/test_pdb.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,66 @@ def test_pdb_next_command_for_coroutine():
779779
finished
780780
"""
781781

782+
def test_pdb_next_command_for_asyncgen():
783+
"""Testing skip unwindng stack on yield for coroutines for "next" command
784+
785+
>>> import asyncio
786+
787+
>>> async def agen():
788+
... yield 1
789+
... await asyncio.sleep(0)
790+
... yield 2
791+
792+
>>> async def test_coro():
793+
... async for x in agen():
794+
... print(x)
795+
796+
>>> async def test_main():
797+
... import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace()
798+
... await test_coro()
799+
800+
>>> def test_function():
801+
... loop = asyncio.new_event_loop()
802+
... loop.run_until_complete(test_main())
803+
... loop.close()
804+
... print("finished")
805+
806+
>>> with PdbTestInput(['step',
807+
... 'step',
808+
... 'next',
809+
... 'next',
810+
... 'step',
811+
... 'next',
812+
... 'continue']):
813+
... test_function()
814+
> <doctest test.test_pdb.test_pdb_next_command_for_asyncgen[3]>(3)test_main()
815+
-> await test_coro()
816+
(Pdb) step
817+
--Call--
818+
> <doctest test.test_pdb.test_pdb_next_command_for_asyncgen[2]>(1)test_coro()
819+
-> async def test_coro():
820+
(Pdb) step
821+
> <doctest test.test_pdb.test_pdb_next_command_for_asyncgen[2]>(2)test_coro()
822+
-> async for x in agen():
823+
(Pdb) next
824+
> <doctest test.test_pdb.test_pdb_next_command_for_asyncgen[2]>(3)test_coro()
825+
-> print(x)
826+
(Pdb) next
827+
1
828+
> <doctest test.test_pdb.test_pdb_next_command_for_asyncgen[2]>(2)test_coro()
829+
-> async for x in agen():
830+
(Pdb) step
831+
--Call--
832+
> <doctest test.test_pdb.test_pdb_next_command_for_asyncgen[1]>(2)agen()
833+
-> yield 1
834+
(Pdb) next
835+
> <doctest test.test_pdb.test_pdb_next_command_for_asyncgen[1]>(3)agen()
836+
-> await asyncio.sleep(0)
837+
(Pdb) continue
838+
2
839+
finished
840+
"""
841+
782842
def test_pdb_return_command_for_generator():
783843
"""Testing no unwindng stack on yield for generators
784844
for "return" command

0 commit comments

Comments
 (0)