MCPcopy Create free account
hub / github.com/fabioz/PyDev.Debugger / test_exception_details

Function test_exception_details

tests_python/test_debugger_json.py:3619–3664  ·  view source on GitHub ↗
(case_setup_dap, max_frames)

Source from the content-addressed store, hash-verified

3617
3618@pytest.mark.parametrize("max_frames", ["default", "all", 10]) # -1 = default, 0 = all, 10 = 10 frames
3619def test_exception_details(case_setup_dap, max_frames):
3620 with case_setup_dap.test_file("_debugger_case_large_exception_stack.py") as writer:
3621 json_facade = JsonFacade(writer)
3622
3623 if max_frames == "all":
3624 json_facade.write_launch(maxExceptionStackFrames=0)
3625 # trace back compresses repeated text
3626 min_expected_lines = 100
3627 max_expected_lines = 220
3628 elif max_frames == "default":
3629 json_facade.write_launch()
3630 # default is all frames
3631 # trace back compresses repeated text
3632 min_expected_lines = 100
3633 max_expected_lines = 220
3634 else:
3635 json_facade.write_launch(maxExceptionStackFrames=max_frames)
3636 min_expected_lines = 10
3637 max_expected_lines = 22
3638
3639 json_facade.write_set_exception_breakpoints(["raised"])
3640
3641 json_facade.write_make_initial_run()
3642 json_hit = json_facade.wait_for_thread_stopped("exception")
3643
3644 exc_info_request = json_facade.write_request(
3645 pydevd_schema.ExceptionInfoRequest(pydevd_schema.ExceptionInfoArguments(json_hit.thread_id))
3646 )
3647 exc_info_response = json_facade.wait_for_response(exc_info_request)
3648
3649 stack_frames = json_hit.stack_trace_response.body.stackFrames
3650 assert 100 <= len(stack_frames) <= 104
3651 assert stack_frames[-1]["name"] == "<module>"
3652 assert stack_frames[0]["name"] == "method1"
3653
3654 body = exc_info_response.body
3655 assert body.exceptionId.endswith("IndexError")
3656 assert body.description == "foo"
3657 assert normcase(body.details.kwargs["source"]) == normcase(writer.TEST_FILE)
3658 stack_line_count = len(body.details.stackTrace.split("\n"))
3659 assert min_expected_lines <= stack_line_count <= max_expected_lines
3660
3661 json_facade.write_set_exception_breakpoints([]) # Don't stop on reraises.
3662 json_facade.write_continue()
3663
3664 writer.finished_ok = True
3665
3666
3667def test_stack_levels(case_setup_dap):

Callers

nothing calls this directly

Calls 10

write_launchMethod · 0.95
write_requestMethod · 0.95
wait_for_responseMethod · 0.95
write_continueMethod · 0.95
JsonFacadeClass · 0.85
normcaseFunction · 0.85
test_fileMethod · 0.80

Tested by

no test coverage detected