(pyfile, target, run)
| 530 | |
| 531 | |
| 532 | def 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 | |
| 577 | def test_set_expression(pyfile, target, run): |
nothing calls this directly
no test coverage detected
searching dependent graphs…