debugpy/tests/func/test_args.py
Pavel Minaev 8f68b3d359
Port refactored command line parser to master (#1105)
* Fix #1090: Port refactored command line parser to master

* Fix #921: Double dash in program arguments gets caught and crashes pydevd

* Fix #1013: -h/--help arg to program instead shows help for interpreter
2019-01-16 20:26:39 -08:00

30 lines
979 B
Python

# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See LICENSE in the project root
# for license information.
from __future__ import print_function, with_statement, absolute_import
from tests.helpers.session import DebugSession
import pytest
@pytest.mark.parametrize('run_as', ['file', 'module', 'code'])
def test_args(pyfile, run_as, start_method):
@pyfile
def code_to_debug():
import sys
from dbgimporter import import_and_enable_debugger
import_and_enable_debugger()
print(sys.argv)
assert sys.argv[1] == '--arg1'
assert sys.argv[2] == 'arg2'
assert sys.argv[3] == '-arg3'
args = ['--arg1', 'arg2', '-arg3']
with DebugSession() as session:
session.initialize(
target=(run_as, code_to_debug),
start_method=start_method,
program_args=args
)
session.start_debugging()
session.wait_for_exit()