mirror of
https://github.com/microsoft/debugpy.git
synced 2025-12-23 08:48:12 +00:00
* Expose CLI Options through public API Expose a public API that can retrieve the processed CLI options for the current process launched through the debugpy CLI. This enables code to be able to retrieve options like the port and adapter access token to be used for launching their own child process' that can be debugged. * Fix test by sending dict not dataclass object
35 lines
931 B
Python
35 lines
931 B
Python
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
# Licensed under the MIT License. See LICENSE in the project root
|
|
# for license information.
|
|
|
|
from tests import debug
|
|
|
|
|
|
def test_cli_options_with_no_debugger():
|
|
import debugpy
|
|
|
|
cli_options = debugpy.get_cli_options()
|
|
assert cli_options is None
|
|
|
|
|
|
def test_cli_options_under_file_connect(pyfile, target, run):
|
|
@pyfile
|
|
def code_to_debug():
|
|
import dataclasses
|
|
import debugpy
|
|
|
|
import debuggee
|
|
from debuggee import backchannel
|
|
|
|
debuggee.setup()
|
|
backchannel.send(dataclasses.asdict(debugpy.get_cli_options()))
|
|
|
|
with debug.Session() as session:
|
|
backchannel = session.open_backchannel()
|
|
|
|
with run(session, target(code_to_debug)):
|
|
pass
|
|
|
|
cli_options = backchannel.receive()
|
|
assert cli_options['mode'] == 'connect'
|
|
assert cli_options['target_kind'] == 'file'
|