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

Function test_set_variable

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

Source from the content-addressed store, hash-verified

530
531
532def test_set_variable(pyfile, target, run):
533 @pyfile
534 def code_to_debug():
535 import debuggee
536 import debugpy
537 from debuggee import backchannel
538
539 debuggee.setup()
540 a = 1
541 debugpy.breakpoint()
542 backchannel.send(a)
543
544 with debug.Session() as session:
545 backchannel = session.open_backchannel()
546 with run(session, target(code_to_debug)):
547 pass
548
549 stop = session.wait_for_stop()
550 scopes = session.request("scopes", {"frameId": stop.frame_id})["scopes"]
551 globals_ref = scopes[0]["variablesReference"]
552 vars = session.request("variables", {"variablesReference": globals_ref})[
553 "variables"
554 ]
555
556 (a,) = (v for v in vars if v["name"] == "a")
557 assert a == some.dict.containing(
558 {
559 "type": "int",
560 "value": "1",
561 "name": "a",
562 "evaluateName": "a",
563 "variablesReference": 0,
564 }
565 )
566
567 set_a = session.request(
568 "setVariable",
569 {"variablesReference": globals_ref, "name": "a", "value": "1000"},
570 )
571 assert set_a == some.dict.containing({"type": "int", "value": "1000"})
572
573 session.request_continue()
574 assert backchannel.receive() == 1000
575
576
577def test_set_expression(pyfile, target, run):

Callers

nothing calls this directly

Calls 7

open_backchannelMethod · 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…