MCPcopy Create free account
hub / github.com/microsoft/debugpy / test_set_expression

Function test_set_expression

tests/debugpy/test_evaluate.py:577–617  ·  view source on GitHub ↗
(pyfile, target, run)

Source from the content-addressed store, hash-verified

575
576
577def test_set_expression(pyfile, target, run):
578 @pyfile
579 def code_to_debug():
580 import debuggee
581 from debuggee import backchannel
582
583 debuggee.setup()
584 a = 1
585 backchannel.send(a) # @bp
586
587 with debug.Session() as session:
588 backchannel = session.open_backchannel()
589 with run(session, target(code_to_debug)):
590 session.set_breakpoints(code_to_debug, all)
591
592 stop = session.wait_for_stop()
593 scopes = session.request("scopes", {"frameId": stop.frame_id})["scopes"]
594 globals_ref = scopes[0]["variablesReference"]
595
596 vars = session.request("variables", {"variablesReference": globals_ref})[
597 "variables"
598 ]
599 (a,) = (v for v in vars if v["name"] == "a")
600 assert a == some.dict.containing(
601 {
602 "type": "int",
603 "value": "1",
604 "name": "a",
605 "evaluateName": "a",
606 "variablesReference": 0,
607 }
608 )
609
610 set_a = session.request(
611 "setExpression",
612 {"frameId": stop.frame_id, "expression": "a", "value": "1000"},
613 )
614 assert set_a == some.dict.containing({"type": "int", "value": "1000"})
615
616 session.request_continue()
617 assert backchannel.receive() == 1000
618
619
620def test_evaluate_thread_locks(pyfile, target, run):

Callers

nothing calls this directly

Calls 8

open_backchannelMethod · 0.80
set_breakpointsMethod · 0.80
wait_for_stopMethod · 0.80
request_continueMethod · 0.80
receiveMethod · 0.80
runFunction · 0.70
targetFunction · 0.70
requestMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…