MCPcopy Index your code
hub / github.com/fabioz/PyDev.Debugger / test_case_completions_json

Function test_case_completions_json

tests_python/test_debugger_json.py:1839–1893  ·  view source on GitHub ↗
(case_setup_dap)

Source from the content-addressed store, hash-verified

1837
1838
1839def test_case_completions_json(case_setup_dap):
1840 with case_setup_dap.test_file("_debugger_case_completions.py") as writer:
1841 json_facade = JsonFacade(writer)
1842
1843 writer.write_add_breakpoint(writer.get_line_index_with_content("Break here"))
1844
1845 json_facade.write_make_initial_run()
1846
1847 first_hit = None
1848 for i in range(2):
1849 json_hit = json_facade.wait_for_thread_stopped()
1850
1851 json_hit = json_facade.get_stack_as_json_hit(json_hit.thread_id)
1852 if i == 0:
1853 first_hit = json_hit
1854
1855 completions_arguments = pydevd_schema.CompletionsArguments("dict.", 6, frameId=json_hit.frame_id, line=0)
1856 completions_request = json_facade.write_request(pydevd_schema.CompletionsRequest(completions_arguments))
1857
1858 response = json_facade.wait_for_response(completions_request)
1859 assert response.success
1860 labels = [x["label"] for x in response.body.targets]
1861 assert set(labels).issuperset(set(["__contains__", "items", "keys", "values"]))
1862
1863 completions_arguments = pydevd_schema.CompletionsArguments("dict.item", 10, frameId=json_hit.frame_id)
1864 completions_request = json_facade.write_request(pydevd_schema.CompletionsRequest(completions_arguments))
1865
1866 response = json_facade.wait_for_response(completions_request)
1867 assert response.success
1868 if IS_JYTHON:
1869 assert response.body.targets == [{"start": 5, "length": 4, "type": "keyword", "label": "items"}]
1870 else:
1871 assert response.body.targets == [{"start": 5, "length": 4, "type": "function", "label": "items"}]
1872
1873 if i == 1:
1874 # Check with a previously existing frameId.
1875 assert first_hit.frame_id != json_hit.frame_id
1876 completions_arguments = pydevd_schema.CompletionsArguments("dict.item", 10, frameId=first_hit.frame_id)
1877 completions_request = json_facade.write_request(pydevd_schema.CompletionsRequest(completions_arguments))
1878
1879 response = json_facade.wait_for_response(completions_request)
1880 assert not response.success
1881 assert response.message == "Thread to get completions seems to have resumed already."
1882
1883 # Check with a never frameId which never existed.
1884 completions_arguments = pydevd_schema.CompletionsArguments("dict.item", 10, frameId=99999)
1885 completions_request = json_facade.write_request(pydevd_schema.CompletionsRequest(completions_arguments))
1886
1887 response = json_facade.wait_for_response(completions_request)
1888 assert not response.success
1889 assert response.message.startswith("Wrong ID sent from the client:")
1890
1891 json_facade.write_continue()
1892
1893 writer.finished_ok = True
1894
1895
1896def test_modules(case_setup_dap):

Callers

nothing calls this directly

Calls 10

get_stack_as_json_hitMethod · 0.95
write_requestMethod · 0.95
wait_for_responseMethod · 0.95
write_continueMethod · 0.95
JsonFacadeClass · 0.85
test_fileMethod · 0.80
write_add_breakpointMethod · 0.80

Tested by

no test coverage detected