forked from microsoft/debugpy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_input.py
More file actions
59 lines (44 loc) · 1.71 KB
/
Copy pathtest_input.py
File metadata and controls
59 lines (44 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See LICENSE in the project root
# for license information.
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"