Skip to content

Add an example to the README

5b9dde5
Select commit
Loading
Failed to load commit list.
Draft

Easy post_mortem #1996

Add an example to the README
5b9dde5
Select commit
Loading
Failed to load commit list.
Azure Pipelines / debugpy-test failed Feb 3, 2026 in 1h 5m 54s

Build #20260203.1 had test failures

Details

Tests

  • Failed: 49 (0.20%)
  • Passed: 20,109 (81.67%)
  • Other: 4,465 (18.13%)
  • Total: 24,623

Annotations

Check failure on line 7056 in Build log

See this annotation in the file changed.

@azure-pipelines azure-pipelines / debugpy-test

Build log #L7056

PowerShell exited with code '1'.

Check failure on line 7008 in Build log

See this annotation in the file changed.

@azure-pipelines azure-pipelines / debugpy-test

Build log #L7008

PowerShell exited with code '1'.

Check failure on line 10004 in Build log

See this annotation in the file changed.

@azure-pipelines azure-pipelines / debugpy-test

Build log #L10004

PowerShell exited with code '1'.

Check failure on line 7095 in Build log

See this annotation in the file changed.

@azure-pipelines azure-pipelines / debugpy-test

Build log #L7095

PowerShell exited with code '1'.

Check failure on line 1 in test_post_mortem_not_as_uncaught[program-launch]

See this annotation in the file changed.

@azure-pipelines azure-pipelines / debugpy-test

test_post_mortem_not_as_uncaught[program-launch]

failed on setup with "worker 'gw2' crashed while running 'tests/debugpy/test_postmortem.py::test_post_mortem_not_as_uncaught[program-launch]'"
Raw output
worker 'gw2' crashed while running 'tests/debugpy/test_postmortem.py::test_post_mortem_not_as_uncaught[program-launch]'

Check failure on line 1 in test_post_mortem_basic[program-launch]

See this annotation in the file changed.

@azure-pipelines azure-pipelines / debugpy-test

test_post_mortem_basic[program-launch]

assert {\n    "exceptionId": "AttributeError",\n    "breakMode": "unhandled",\n    "description": "module '_pydevd_sys_monitorin...93yx3lnxm0n2_lrgr0000gn/T/pytest-of-runner/pytest-0/popen-gw4/test_post_mortem_basic_program0/code_to_debug.py"\n    }\n} == {'exceptionId': /(.+\\.)?ValueError/, 'description': 'something went wrong', 'breakMode': 'unhandled', ...}
 +  where {'exceptionId': /(.+\\.)?ValueError/, 'description': 'something went wrong', 'breakMode': 'unhandled', ...} = <class 'tests.patterns._impl.DictContaining'>({'breakMode': 'unhandled', 'description': 'something went wrong', 'exceptionId': /(.+\\.)?ValueError/})
 +    where <class 'tests.patterns._impl.DictContaining'> = <dict>.containing
 +      where <dict> = some.dict
Raw output
pyfile = <function pyfile.<locals>.factory at 0x104c262a0>
target = <class 'tests.debug.targets.Program'>, run = launch

    def test_post_mortem_basic(pyfile, target, run):
        """Calling post_mortem() inside an except block should stop the debugger."""
    
        @pyfile
        def code_to_debug():
            import debuggee
            debuggee.setup()
    
            import debugpy
    
            def risky_operation():
                raise ValueError("something went wrong")  # @raise
    
            try:
                risky_operation()
            except ValueError:
                debugpy.post_mortem()
    
        with debug.Session() as session:
            with run(session, target(code_to_debug)):
                session.request("setExceptionBreakpoints", {"filters": ["uncaught"]})
    
            occ = session.wait_for_next(
                Event("stopped") | Event("terminated"),
            )
    
            if occ.event == "terminated":
                pytest.fail("Debuggee exited without hitting breakpoint")
    
            exc_info = session.request("exceptionInfo", {"threadId": occ.body['threadId']})
>           assert exc_info == some.dict.containing(
                {
                    "exceptionId": some.str.matching(r"(.+\.)?ValueError"),
                    "description": "something went wrong",
                    "breakMode": "unhandled",
                }
            )
E           assert {\n    "exceptionId": "AttributeError",\n    "breakMode": "unhandled",\n    "description": "module '_pydevd_sys_monitorin...93yx3lnxm0n2_lrgr0000gn/T/pytest-of-runner/pytest-0/popen-gw4/test_post_mortem_basic_program0/code_to_debug.py"\n    }\n} == {'exceptionId': /(.+\\.)?ValueError/, 'description': 'something went wrong', 'breakMode': 'unhandled', ...}
E            +  where {'exceptionId': /(.+\\.)?ValueError/, 'description': 'something went wrong', 'breakMode': 'unhandled', ...} = <class 'tests.patterns._impl.DictContaining'>({'breakMode': 'unhandled', 'description': 'something went wrong', 'exceptionId': /(.+\\.)?ValueError/})
E            +    where <class 'tests.patterns._impl.DictContaining'> = <dict>.containing
E            +      where <dict> = some.dict

tests/debugpy/test_postmortem.py:41: AssertionError

Check failure on line 1 in test_post_mortem_basic_no_uncaught_breakpoint[program-launch]

See this annotation in the file changed.

@azure-pipelines azure-pipelines / debugpy-test

test_post_mortem_basic_no_uncaught_breakpoint[program-launch]

failed on setup with "worker 'gw4' crashed while running 'tests/debugpy/test_postmortem.py::test_post_mortem_basic_no_uncaught_breakpoint[program-launch]'"
Raw output
worker 'gw4' crashed while running 'tests/debugpy/test_postmortem.py::test_post_mortem_basic_no_uncaught_breakpoint[program-launch]'

Check failure on line 1 in test_post_mortem_basic_with_exception[program-launch]

See this annotation in the file changed.

@azure-pipelines azure-pipelines / debugpy-test

test_post_mortem_basic_with_exception[program-launch]

assert {\n    "exceptionId": "AttributeError",\n    "breakMode": "unhandled",\n    "description": "module '_pydevd_sys_monitorin...93yx3lnxm0n2_lrgr0000gn/T/pytest-of-runner/pytest-0/popen-gw4/test_post_mortem_basic_with_ex0/code_to_debug.py"\n    }\n} == {'exceptionId': /(.+\\.)?ValueError/, 'description': 'something went wrong', 'breakMode': 'unhandled', ...}
 +  where {'exceptionId': /(.+\\.)?ValueError/, 'description': 'something went wrong', 'breakMode': 'unhandled', ...} = <class 'tests.patterns._impl.DictContaining'>({'breakMode': 'unhandled', 'description': 'something went wrong', 'exceptionId': /(.+\\.)?ValueError/})
 +    where <class 'tests.patterns._impl.DictContaining'> = <dict>.containing
 +      where <dict> = some.dict
Raw output
pyfile = <function pyfile.<locals>.factory at 0x104c24220>
target = <class 'tests.debug.targets.Program'>, run = launch

    def test_post_mortem_basic_with_exception(pyfile, target, run):
        """Can call post_mortem(e) with an exception alone."""
    
        @pyfile
        def code_to_debug():
            import debuggee
            debuggee.setup()
    
            import debugpy
    
            def risky_operation():
                raise ValueError("something went wrong")  # @raise
    
            try:
                risky_operation()
            except ValueError as e:
                debugpy.post_mortem(e)
    
        with debug.Session() as session:
            with run(session, target(code_to_debug)):
                session.request("setExceptionBreakpoints", {"filters": ["uncaught"]})
    
            occ = session.wait_for_next(
                Event("stopped") | Event("terminated"),
            )
    
            if occ.event == "terminated":
                pytest.fail("Debuggee exited without hitting breakpoint")
    
            exc_info = session.request("exceptionInfo", {"threadId": occ.body['threadId']})
>           assert exc_info == some.dict.containing(
                {
                    "exceptionId": some.str.matching(r"(.+\.)?ValueError"),
                    "description": "something went wrong",
                    "breakMode": "unhandled",
                }
            )
E           assert {\n    "exceptionId": "AttributeError",\n    "breakMode": "unhandled",\n    "description": "module '_pydevd_sys_monitorin...93yx3lnxm0n2_lrgr0000gn/T/pytest-of-runner/pytest-0/popen-gw4/test_post_mortem_basic_with_ex0/code_to_debug.py"\n    }\n} == {'exceptionId': /(.+\\.)?ValueError/, 'description': 'something went wrong', 'breakMode': 'unhandled', ...}
E            +  where {'exceptionId': /(.+\\.)?ValueError/, 'description': 'something went wrong', 'breakMode': 'unhandled', ...} = <class 'tests.patterns._impl.DictContaining'>({'breakMode': 'unhandled', 'description': 'something went wrong', 'exceptionId': /(.+\\.)?ValueError/})
E            +    where <class 'tests.patterns._impl.DictContaining'> = <dict>.containing
E            +      where <dict> = some.dict

tests/debugpy/test_postmortem.py:81: AssertionError