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

Function test_stack_and_variables_dict

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

Source from the content-addressed store, hash-verified

1995
1996@pytest.mark.skipif(IS_JYTHON, reason="Putting unicode on frame vars does not work on Jython.")
1997def test_stack_and_variables_dict(case_setup_dap):
1998 with case_setup_dap.test_file("_debugger_case_local_variables.py") as writer:
1999 json_facade = JsonFacade(writer)
2000
2001 writer.write_add_breakpoint(writer.get_line_index_with_content("Break 2 here"))
2002 json_facade.write_make_initial_run()
2003
2004 json_hit = json_facade.wait_for_thread_stopped()
2005 json_hit = json_facade.get_stack_as_json_hit(json_hit.thread_id)
2006
2007 variables_response = json_facade.get_variables_response(json_hit.frame_id)
2008
2009 variables_references = json_facade.pop_variables_reference(variables_response.body.variables)
2010 dict_variable_reference = variables_references[2]
2011 assert isinstance(dict_variable_reference, int_types)
2012 # : :type variables_response: VariablesResponse
2013
2014 expected_unicode = {
2015 "name": "\u16a0",
2016 "value": "'\u16a1'",
2017 "type": "str",
2018 "presentationHint": {"attributes": ["rawString"]},
2019 "evaluateName": "\u16a0",
2020 }
2021 assert variables_response.body.variables == [
2022 {"name": "variable_for_test_1", "value": "10", "type": "int", "evaluateName": "variable_for_test_1"},
2023 {"name": "variable_for_test_2", "value": "20", "type": "int", "evaluateName": "variable_for_test_2"},
2024 {"name": "variable_for_test_3", "value": "{'a': 30, 'b': 20}", "type": "dict", "evaluateName": "variable_for_test_3"},
2025 expected_unicode,
2026 ]
2027
2028 variables_response = json_facade.get_variables_response(dict_variable_reference)
2029 check = [x for x in variables_response.body.variables if x["name"] not in DAPGrouper.SCOPES_SORTED]
2030 assert check == [
2031 {"name": "'a'", "value": "30", "type": "int", "evaluateName": "variable_for_test_3['a']", "variablesReference": 0},
2032 {"name": "'b'", "value": "20", "type": "int", "evaluateName": "variable_for_test_3['b']", "variablesReference": 0},
2033 {
2034 "name": GENERATED_LEN_ATTR_NAME,
2035 "value": "2",
2036 "type": "int",
2037 "evaluateName": "len(variable_for_test_3)",
2038 "variablesReference": 0,
2039 "presentationHint": {"attributes": ["readOnly"]},
2040 },
2041 ]
2042
2043 json_facade.write_continue()
2044 writer.finished_ok = True
2045
2046
2047def test_variables_with_same_name(case_setup_dap):

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected