(case_setup_dap, tmpdir)
| 4734 | |
| 4735 | @pytest.mark.skipif(not IS_CPYTHON, reason="CPython only test.") |
| 4736 | def test_linecache_json(case_setup_dap, tmpdir): |
| 4737 | with case_setup_dap.test_file("_debugger_case_linecache.py") as writer: |
| 4738 | json_facade = JsonFacade(writer) |
| 4739 | |
| 4740 | json_facade.write_launch(justMyCode=False) |
| 4741 | |
| 4742 | writer.write_add_breakpoint(writer.get_line_index_with_content("breakpoint")) |
| 4743 | json_facade.write_make_initial_run() |
| 4744 | |
| 4745 | # First hit is for breakpoint reached via a stack frame that doesn't have source. |
| 4746 | |
| 4747 | json_hit = json_facade.wait_for_thread_stopped() |
| 4748 | stack_trace_response_body = json_hit.stack_trace_response.body |
| 4749 | source_references = [] |
| 4750 | for stack_frame in stack_trace_response_body.stackFrames: |
| 4751 | if stack_frame["source"]["path"] == "<foo bar>": |
| 4752 | source_reference = stack_frame["source"]["sourceReference"] |
| 4753 | assert source_reference != 0 |
| 4754 | source_references.append(source_reference) |
| 4755 | |
| 4756 | # Each frame gets its own source reference. |
| 4757 | assert len(set(source_references)) == 2 |
| 4758 | |
| 4759 | for source_reference in source_references: |
| 4760 | response = json_facade.write_get_source(source_reference) |
| 4761 | assert "def somemethod():" in response.body.content |
| 4762 | assert " foo()" in response.body.content |
| 4763 | assert "[x for x in range(10)]" in response.body.content |
| 4764 | |
| 4765 | json_facade.write_continue() |
| 4766 | writer.finished_ok = True |
| 4767 | |
| 4768 | |
| 4769 | @pytest.mark.skipif(not IS_CPYTHON, reason="CPython only test.") |
nothing calls this directly
no test coverage detected