@@ -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+
782842def test_pdb_return_command_for_generator ():
783843 """Testing no unwindng stack on yield for generators
784844 for "return" command
0 commit comments