Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Prev Previous commit
Next Next commit
Add breakpoint tests
  • Loading branch information
gaogaotiantian committed Apr 16, 2025
commit 50c3c9c5117309209a40c9d4ef313b257c0875f4
53 changes: 53 additions & 0 deletions Lib/test/test_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -2233,6 +2233,59 @@ def test_pdb_await_support():
(Pdb) continue
"""

def test_pdb_await_with_breakpoint():
"""Testing await support with breakpoints set in tasks

>>> reset_Breakpoint()

>>> import asyncio

>>> async def test():
... x = 2
... await asyncio.sleep(0)
... return 42

>>> async def main():
... import pdb;
... task = asyncio.create_task(test())
... await pdb.Pdb(nosigint=True, readrc=False).set_trace_async()

>>> def test_function():
... asyncio.run(main(), loop_factory=asyncio.EventLoop)

>>> with PdbTestInput([ # doctest: +ELLIPSIS
... 'b test',
... 'k = await task',
... 'n',
... 'p x',
... 'continue',
... 'p k',
... 'clear 1',
... 'continue',
... ]):
... test_function()
> <doctest test.test_pdb.test_pdb_await_with_breakpoint[3]>(4)main()
-> await pdb.Pdb(nosigint=True, readrc=False).set_trace_async()
(Pdb) b test
Breakpoint 1 at <doctest test.test_pdb.test_pdb_await_with_breakpoint[2]>:2
(Pdb) k = await task
> <doctest test.test_pdb.test_pdb_await_with_breakpoint[2]>(2)test()
-> x = 2
(Pdb) n
> <doctest test.test_pdb.test_pdb_await_with_breakpoint[2]>(3)test()
-> await asyncio.sleep(0)
(Pdb) p x
2
(Pdb) continue
> <doctest test.test_pdb.test_pdb_await_with_breakpoint[3]>(4)main()
-> await pdb.Pdb(nosigint=True, readrc=False).set_trace_async()
(Pdb) p k
42
(Pdb) clear 1
Deleted breakpoint 1 at <doctest test.test_pdb.test_pdb_await_with_breakpoint[2]>:2
(Pdb) continue
"""

def test_pdb_next_command_for_coroutine():
"""Testing skip unwinding stack on yield for coroutines for "next" command

Expand Down
Loading