forked from microsoft/debugpy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix microsoft#370: Terminal Keyboard Inputs not being accepted
Make the debuggee process group the foreground group in its session. Add a test for input(), and improve existing stdin test to cover more cases.
- Loading branch information
Showing
3 changed files
with
87 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See LICENSE in the project root | ||
# for license information. | ||
|
||
from __future__ import absolute_import, division, print_function, unicode_literals | ||
|
||
import pytest | ||
|
||
from tests import debug | ||
from tests.debug import runners | ||
|
||
|
||
@pytest.mark.parametrize("run", runners.all) | ||
@pytest.mark.parametrize("redirect_output", ["", "redirect_output"]) | ||
def test_stdin_not_patched(pyfile, target, run, redirect_output): | ||
@pyfile | ||
def code_to_debug(): | ||
import sys | ||
import debuggee | ||
from debuggee import backchannel | ||
|
||
debuggee.setup() | ||
backchannel.send(sys.stdin is sys.__stdin__) | ||
|
||
with debug.Session() as session: | ||
session.config["redirectOutput"] = bool(redirect_output) | ||
|
||
backchannel = session.open_backchannel() | ||
with run(session, target(code_to_debug)): | ||
pass | ||
|
||
is_original_stdin = backchannel.receive() | ||
assert is_original_stdin, "Expected sys.stdin and sys.__stdin__ to be the same." | ||
|
||
|
||
@pytest.mark.parametrize("run", runners.all_launch_terminal + runners.all_attach) | ||
@pytest.mark.parametrize("redirect_output", ["", "redirect_output"]) | ||
def test_input(pyfile, target, run, redirect_output): | ||
@pyfile | ||
def code_to_debug(): | ||
import debuggee | ||
from debuggee import backchannel | ||
|
||
try: | ||
input = raw_input | ||
except NameError: | ||
pass | ||
|
||
debuggee.setup() | ||
backchannel.send(input()) | ||
|
||
with debug.Session() as session: | ||
session.config["redirectOutput"] = bool(redirect_output) | ||
|
||
backchannel = session.open_backchannel() | ||
with run(session, target(code_to_debug)): | ||
pass | ||
|
||
session.debuggee.stdin.write(b"ok\n") | ||
s = backchannel.receive() | ||
assert s == "ok" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters