Skip to content

Commit 4f4ef0a

Browse files
authored
Add a test for pdb until command in coroutine (#5427)
1 parent 66e5742 commit 4f4ef0a

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

Lib/test/test_pdb.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,52 @@ def test_pdb_until_command_for_generator():
982982
finished
983983
"""
984984

985+
def test_pdb_until_command_for_coroutine():
986+
"""Testing no unwindng stack for coroutines
987+
for "until" command if target breakpoing is not reached
988+
989+
>>> import asyncio
990+
991+
>>> async def test_coro():
992+
... print(0)
993+
... await asyncio.sleep(0)
994+
... print(1)
995+
... await asyncio.sleep(0)
996+
... print(2)
997+
... await asyncio.sleep(0)
998+
... print(3)
999+
1000+
>>> async def test_main():
1001+
... import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace()
1002+
... await test_coro()
1003+
1004+
>>> def test_function():
1005+
... loop = asyncio.new_event_loop()
1006+
... loop.run_until_complete(test_main())
1007+
... loop.close()
1008+
... print("finished")
1009+
1010+
>>> with PdbTestInput(['step',
1011+
... 'until 8',
1012+
... 'continue']):
1013+
... test_function()
1014+
> <doctest test.test_pdb.test_pdb_until_command_for_coroutine[2]>(3)test_main()
1015+
-> await test_coro()
1016+
(Pdb) step
1017+
--Call--
1018+
> <doctest test.test_pdb.test_pdb_until_command_for_coroutine[1]>(1)test_coro()
1019+
-> async def test_coro():
1020+
(Pdb) until 8
1021+
0
1022+
1
1023+
2
1024+
> <doctest test.test_pdb.test_pdb_until_command_for_coroutine[1]>(8)test_coro()
1025+
-> print(3)
1026+
(Pdb) continue
1027+
3
1028+
finished
1029+
"""
1030+
9851031
def test_pdb_next_command_in_generator_for_loop():
9861032
"""The next command on returning from a generator controlled by a for loop.
9871033

0 commit comments

Comments
 (0)