Fix #1811: tests using attach_by_pid fail on Python 2.7

Don't call enable_attach() and wait_for_attach() while under import lock.
This commit is contained in:
Pavel Minaev 2020-01-24 22:06:42 -08:00
parent 1e3fe90339
commit 55eac82c96
34 changed files with 214 additions and 122 deletions

View file

@ -8,14 +8,8 @@ from __future__ import absolute_import, division, print_function, unicode_litera
to establish connection back to DebugSession in the test process, depending on
DebugSession.start_method used by the test.
This module MUST be imported by all code that is executed via DebugSession, unless
it is launched with start_method="custom_client", for tests that need to set up
debugpy and establish the connection themselves in some special manner.
If the code needs to access debugpy and/or pydevd, this module additionally exports
both as global variables, specifically so that it is possible to write::
from debug_me import debugpy, pydevd, backchannel
This module MUST be imported, and setup() must be called, by all test scripts that
are run via debug.Session and the standard runners.
"""
__all__ = ["debugpy", "pydevd", "session_id"]
@ -38,13 +32,8 @@ scratchpad = {}
# Some runners require code to be executed in the debuggee process, either to set up
# the debug server, or to ensure that it doesn't run any other code until the debugger
# is attached. This provides a facility to inject such code.
_code = os.environ.pop("DEBUGPY_TEST_DEBUG_ME", None)
if _code:
_code = compile(_code, "<DEBUGPY_TEST_DEBUG_ME>", "exec")
eval(_code, {})
# For `from debug_me import ...`.
import debugpy
import debugpy.server
import pydevd
def setup():
_code = os.environ.pop("DEBUGPY_TEST_DEBUGGEE_SETUP", None)
if _code:
_code = compile(_code, "<DEBUGPY_TEST_DEBUGGEE_SETUP>", "exec")
eval(_code, {})

View file

@ -14,7 +14,7 @@ import atexit
import os
import socket
import debug_me
import debuggee
from debugpy.common import fmt, log, messaging
@ -54,7 +54,7 @@ class _stream:
close = lambda: None
name = fmt("backchannel-{0}", debug_me.session_id)
name = fmt("backchannel-{0}", debuggee.session_id)
port = os.environ.pop("DEBUGPY_TEST_BACKCHANNEL_PORT", None)
if port is not None:
port = int(port)

View file

@ -117,8 +117,8 @@ class ScratchPad(object):
raise NotImplementedError
def __setitem__(self, key, value):
"""Sets debug_me.scratchpad[key] = value inside the debugged process.
"""Sets debuggee.scratchpad[key] = value inside the debugged process.
"""
log.info("{0} debug_me.scratchpad[{1!r}] = {2!r}", self.session, key, value)
expr = fmt("sys.modules['debug_me'].scratchpad[{0!r}] = {1!r}", key, value)
log.info("{0} debuggee.scratchpad[{1!r}] = {2!r}", self.session, key, value)
expr = fmt("sys.modules['debuggee'].scratchpad[{0!r}] = {1!r}", key, value)
self.session.request("evaluate", {"context": "repl", "expression": expr})

View file

@ -146,8 +146,8 @@ def launch(session, target, console="integratedTerminal", cwd=None):
def _attach_common_config(session, target, cwd):
assert target.code is None or "debug_me" in target.code, fmt(
"{0} must import debug_me.", target.filename
assert target.code is None or "debuggee.setup()" in target.code, fmt(
"{0} must invoke debuggee.setup().", target.filename
)
target.configure(session)
@ -160,8 +160,6 @@ def _attach_common_config(session, target, cwd):
@_runner
@contextlib.contextmanager
def attach_by_pid(session, target, cwd=None, wait=True):
if sys.version_info < (3,) and sys.platform == "win32":
pytest.skip("https://github.com/microsoft/ptvsd/issues/1811")
if sys.version_info < (3,) and sys.platform == "darwin":
pytest.skip("https://github.com/microsoft/ptvsd/issues/1916")
if wait and not sys.platform.startswith("linux"):
@ -180,7 +178,7 @@ def attach_by_pid(session, target, cwd=None, wait=True):
args = target.cli(session.spawn_debuggee.env)
if wait:
debug_me = """
debuggee_setup = """
import sys
import threading
import time
@ -188,15 +186,15 @@ import time
while "debugpy" not in sys.modules:
time.sleep(0.1)
from debug_me import scratchpad
from debuggee import scratchpad
while "_attach_by_pid" not in scratchpad:
time.sleep(0.1)
"""
else:
debug_me = None
debuggee_setup = None
session.spawn_debuggee(args, cwd=cwd, debug_me=debug_me)
session.spawn_debuggee(args, cwd=cwd, setup=debuggee_setup)
config["processId"] = session.debuggee.pid
session.spawn_adapter()
@ -230,22 +228,22 @@ def attach_by_socket(
args += ["--host", compat.filename_str(host), "--port", str(port)]
if log_dir is not None:
args += ["--log-dir", log_dir]
debug_me = None
debuggee_setup = None
elif method == "api":
args = []
debug_me = """
debuggee_setup = """
import debugpy
debugpy.enable_attach(({host!r}, {port!r}), {args})
if {wait!r}:
debugpy.wait_for_attach()
"""
attach_args = "" if log_dir is None else fmt("log_dir={0!r}", log_dir)
debug_me = fmt(debug_me, host=host, port=port, wait=wait, args=attach_args)
debuggee_setup = fmt(debuggee_setup, host=host, port=port, wait=wait, args=attach_args)
else:
raise ValueError
args += target.cli(session.spawn_debuggee.env)
session.spawn_debuggee(args, cwd=cwd, debug_me=debug_me)
session.spawn_debuggee(args, cwd=cwd, setup=debuggee_setup)
if wait:
session.wait_for_enable_attach()

View file

@ -334,7 +334,7 @@ class Session(object):
return env
def spawn_debuggee(self, args, cwd=None, exe=sys.executable, debug_me=None):
def spawn_debuggee(self, args, cwd=None, exe=sys.executable, setup=None):
assert self.debuggee is None
assert not len(self.captured_output - {"stdout", "stderr"})
@ -349,8 +349,8 @@ class Session(object):
env["DEBUGPY_ADAPTER_ENDPOINTS"] = self.adapter_endpoints = (
self.tmpdir / "adapter_endpoints"
)
if debug_me is not None:
env["DEBUGPY_TEST_DEBUG_ME"] = debug_me
if setup is not None:
env["DEBUGPY_TEST_DEBUGGEE_SETUP"] = setup
log.info(
"Spawning {0}:\n\n"

View file

@ -16,9 +16,11 @@ from tests.patterns import some
def test_args(pyfile, target, run):
@pyfile
def code_to_debug():
from debug_me import backchannel
import sys
import debuggee
from debuggee import backchannel
debuggee.setup()
backchannel.send(sys.argv)
args = ["--arg1", "arg2", "-arg3", "--", "arg4", "-a"]

View file

@ -18,10 +18,13 @@ from tests.patterns import some
def test_attach_api(pyfile, target, wait_for_attach, is_attached, stop_method):
@pyfile
def code_to_debug():
from debug_me import backchannel, debugpy, scratchpad
import debuggee
import debugpy
import sys
import time
from debuggee import backchannel, scratchpad
debuggee.setup()
_, host, port, wait_for_attach, is_attached, stop_method = sys.argv
port = int(port)
debugpy.enable_attach((host, port))
@ -91,9 +94,12 @@ def test_attach_api(pyfile, target, wait_for_attach, is_attached, stop_method):
def test_reattach(pyfile, target, run):
@pyfile
def code_to_debug():
from debug_me import debugpy, scratchpad
import time
import debuggee
import debugpy
from debuggee import backchannel, scratchpad
debuggee.setup()
debugpy.break_into_debugger()
object() # @first
@ -134,9 +140,11 @@ def test_reattach(pyfile, target, run):
def test_attach_by_pid(pyfile, target, pid_type):
@pyfile
def code_to_debug():
import debug_me # noqa
import debuggee
import time
debuggee.setup()
def do_something(i):
time.sleep(0.1)
proceed = True

View file

@ -77,8 +77,9 @@ def test_conditional_breakpoint(pyfile, target, run, condition_kind, condition):
@pyfile
def code_to_debug():
import debug_me # noqa
import debuggee
debuggee.setup()
for i in range(1, 10):
print(i) # @bp
@ -110,16 +111,18 @@ def test_conditional_breakpoint(pyfile, target, run, condition_kind, condition):
def test_crossfile_breakpoint(pyfile, target, run):
@pyfile
def script1():
import debug_me # noqa
import debuggee
debuggee.setup()
def do_something():
print("do something") # @bp
@pyfile
def script2():
import debug_me # noqa
import debuggee
import script1
debuggee.setup()
script1.do_something() # @bp
print("Done")
@ -149,8 +152,9 @@ def test_error_in_condition(pyfile, target, run, error_name):
@pyfile
def code_to_debug():
import debug_me # noqa
import debuggee
debuggee.setup()
for i in range(1, 10): # @bp
pass
@ -180,9 +184,10 @@ def test_error_in_condition(pyfile, target, run, error_name):
def test_log_point(pyfile, target, run, condition):
@pyfile
def code_to_debug():
import debug_me # noqa
import debuggee
import sys
debuggee.setup()
for i in range(0, 10):
sys.stderr.write(str(i * 10) + "\n") # @bp
sys.stderr.flush()
@ -257,8 +262,9 @@ def test_breakpoint_in_package_main(run):
def test_add_and_remove_breakpoint(pyfile, target, run):
@pyfile
def code_to_debug():
import debug_me # noqa
import debuggee
debuggee.setup()
for i in range(0, 10):
print(i) # @bp
() # @wait_for_output
@ -290,7 +296,9 @@ def test_add_and_remove_breakpoint(pyfile, target, run):
def test_breakpoint_in_nonexistent_file(pyfile, target, run):
@pyfile
def code_to_debug():
import debug_me # noqa
import debuggee
debuggee.setup()
with debug.Session() as session:
with run(session, target(code_to_debug)):
@ -310,7 +318,9 @@ def test_breakpoint_in_nonexistent_file(pyfile, target, run):
def test_invalid_breakpoints(pyfile, target, run):
@pyfile
def code_to_debug():
import debug_me # noqa
import debuggee
debuggee.setup()
# fmt: off
b = True
@ -377,7 +387,9 @@ def test_invalid_breakpoints(pyfile, target, run):
def test_deep_stacks(pyfile, target, run):
@pyfile
def code_to_debug():
import debug_me # noqa
import debuggee
debuggee.setup()
def deep_stack(level):
if level <= 0:
@ -417,9 +429,11 @@ def test_break_api(pyfile, target, run, func):
@pyfile
def code_to_debug():
from debug_me import debugpy # noqa
import debuggee
import debugpy
import sys
debuggee.setup()
func = eval(sys.argv[1])
func()
print("break here") # @break

View file

@ -33,7 +33,9 @@ expected_at_line = {
def test_completions_scope(pyfile, line, target, run):
@pyfile
def code_to_debug():
import debug_me # noqa
import debuggee
debuggee.setup()
class SomeClass:
def __init__(self, someVar):
@ -69,8 +71,9 @@ def test_completions_scope(pyfile, line, target, run):
def test_completions_cases(pyfile, target, run):
@pyfile
def code_to_debug():
import debug_me # noqa
import debuggee
debuggee.setup()
a = 1
b = {"one": 1, "two": 2}
c = 3

View file

@ -16,8 +16,10 @@ from tests.patterns import some
def test_continue_on_disconnect_for_attach(pyfile, target, run):
@pyfile
def code_to_debug():
from debug_me import backchannel
import debuggee
from debuggee import backchannel
debuggee.setup()
backchannel.send("continued") # @bp
with debug.Session() as session:
@ -36,9 +38,10 @@ def test_continue_on_disconnect_for_attach(pyfile, target, run):
def test_exit_on_disconnect_for_launch(pyfile, target, run):
@pyfile
def code_to_debug():
import debug_me # noqa
import debuggee
import sys
debuggee.setup()
filename = sys.argv[1] # @bp
# Disconnect happens here; subsequent lines should not run.
with open(filename, "w") as f:

View file

@ -14,8 +14,9 @@ from tests.patterns import some
def test_evaluate(pyfile, target, run):
@pyfile
def code_to_debug():
import debug_me # noqa
import debuggee
debuggee.setup()
a = 1
b = {"one": 1, 2: "two"}
print(a, b) # @bp
@ -50,8 +51,9 @@ def test_evaluate(pyfile, target, run):
def test_variables(pyfile, target, run):
@pyfile
def code_to_debug():
import debug_me # noqa
import debuggee
debuggee.setup()
a = 1
b = {"one": 1, 2: "two"}
c = 3
@ -113,8 +115,9 @@ def test_variables(pyfile, target, run):
def test_variable_sort(pyfile, target, run):
@pyfile
def code_to_debug():
import debug_me # noqa
import debuggee
debuggee.setup()
b_test = {"spam": "A", "eggs": "B", "abcd": "C"} # noqa
_b_test = 12 # noqa
__b_test = 13 # noqa
@ -181,7 +184,9 @@ def test_variable_sort(pyfile, target, run):
def test_return_values(pyfile, target, run, ret_vis):
@pyfile
def code_to_debug():
import debug_me # noqa
import debuggee
debuggee.setup()
class MyClass(object):
def do_something(self):
@ -253,11 +258,13 @@ def test_return_values(pyfile, target, run, ret_vis):
def test_unicode(pyfile, target, run):
@pyfile
def code_to_debug():
from debug_me import debugpy
import debuggee
import debugpy
# Since Unicode variable name is a SyntaxError at parse time in Python 2,
# this needs to do a roundabout way of setting it to avoid parse issues.
globals()["\u16A0"] = 123
debuggee.setup()
debugpy.break_into_debugger()
print("break")
@ -281,8 +288,9 @@ def test_unicode(pyfile, target, run):
def test_hex_numbers(pyfile, target, run):
@pyfile
def code_to_debug():
import debug_me # noqa
import debuggee
debuggee.setup()
a = 100
b = [1, 10, 100]
c = {10: 10, 100: 100, 1000: 1000}
@ -506,8 +514,11 @@ def test_hex_numbers(pyfile, target, run):
def test_set_variable(pyfile, target, run):
@pyfile
def code_to_debug():
from debug_me import backchannel, debugpy
import debuggee
import debugpy
from debuggee import backchannel
debuggee.setup()
a = 1
debugpy.break_into_debugger()
backchannel.send(a)
@ -548,8 +559,10 @@ def test_set_variable(pyfile, target, run):
def test_set_expression(pyfile, target, run):
@pyfile
def code_to_debug():
from debug_me import backchannel
import debuggee
from debuggee import backchannel
debuggee.setup()
a = 1
backchannel.send(a) # @bp

View file

@ -20,7 +20,9 @@ str_matching_ArithmeticError = some.str.matching(r"(.+\.)?ArithmeticError")
def test_vsc_exception_options_raise_with_except(pyfile, target, run, raised, uncaught):
@pyfile
def code_to_debug():
import debug_me # noqa
import debuggee
debuggee.setup()
def raise_with_except():
try:
@ -75,7 +77,9 @@ def test_vsc_exception_options_raise_without_except(
):
@pyfile
def code_to_debug():
import debug_me # noqa
import debuggee
debuggee.setup()
def raise_without_except():
raise ArithmeticError("bad code") # @exc
@ -157,9 +161,10 @@ def test_vsc_exception_options_raise_without_except(
def test_systemexit(pyfile, target, run, raised, uncaught, zero, exit_code):
@pyfile
def code_to_debug():
import debug_me # noqa
import debuggee
import sys
debuggee.setup()
exit_code = eval(sys.argv[1])
print("sys.exit(%r)" % (exit_code,))
try:
@ -231,8 +236,9 @@ def test_raise_exception_options(pyfile, target, run, exceptions, break_mode):
@pyfile
def code_to_debug():
import debug_me # noqa
import debuggee
debuggee.setup()
raise AssertionError() # @AssertionError
else:
@ -243,7 +249,9 @@ def test_raise_exception_options(pyfile, target, run, exceptions, break_mode):
@pyfile
def code_to_debug():
import debug_me # noqa
import debuggee
debuggee.setup()
try:
raise RuntimeError() # @RuntimeError
@ -299,9 +307,10 @@ def test_success_exitcodes(
):
@pyfile
def code_to_debug():
import debug_me # noqa
import debuggee
import sys
debuggee.setup()
exit_code = eval(sys.argv[1])
print("sys.exit(%r)" % (exit_code,))
sys.exit(exit_code)
@ -327,7 +336,9 @@ def test_success_exitcodes(
def test_exception_stack(pyfile, target, run, max_frames):
@pyfile
def code_to_debug():
import debug_me # noqa
import debuggee
debuggee.setup()
def do_something(n):
if n <= 0:

View file

@ -23,17 +23,19 @@ def test_exceptions_and_exclude_rules(pyfile, target, run, scenario, exc_type):
@pyfile
def code_to_debug():
import debug_me # noqa
import debuggee
debuggee.setup()
raise RuntimeError("unhandled error") # @raise_line
elif exc_type == "SystemExit":
@pyfile
def code_to_debug():
import debug_me # noqa
import debuggee
import sys
debuggee.setup()
sys.exit(1) # @raise_line
else:
@ -66,9 +68,11 @@ def test_exceptions_and_partial_exclude_rules(pyfile, target, run, scenario):
@pyfile
def code_to_debug():
from debug_me import backchannel
import debuggee
import sys
from debuggee import backchannel
debuggee.setup()
call_me_back_dir = backchannel.receive()
sys.path.insert(0, call_me_back_dir)

View file

@ -57,7 +57,7 @@ def start_flask(run):
args += ["--port", str(flask_server.port)]
if multiprocess and run.request == "attach":
# For multiproc attach, we need to use a helper stub to import debug_me
# For multiproc attach, we need to use a helper stub to import debuggee
# before running Flask; otherwise, we will get the connection only from
# the subprocess, not from the Flask server process.
target = targets.Program(paths.main_py, args=args)

View file

@ -16,8 +16,9 @@ from tests.patterns import some
def test_justmycode_frames(pyfile, target, run, jmc):
@pyfile
def code_to_debug():
import debug_me # noqa
import debuggee
debuggee.setup()
print("break here") # @bp
with debug.Session() as session:

View file

@ -35,7 +35,9 @@ def check_logs(tmpdir, run):
def test_log_dir(pyfile, tmpdir, target, method):
@pyfile
def code_to_debug():
import debug_me # noqa
import debuggee
debuggee.setup()
# Depending on the method, attach_by_socket will use either `debugpy --log-dir ...`
# or `enable_attach(log_dir=) ...`.
@ -53,8 +55,10 @@ def test_log_dir(pyfile, tmpdir, target, method):
def test_log_dir_env(pyfile, tmpdir, run, target):
@pyfile
def code_to_debug():
from debug_me import backchannel # noqa
import debuggee
from debuggee import backchannel
debuggee.setup()
assert backchannel.receive() == "proceed"
with check_logs(tmpdir, run):

View file

@ -32,13 +32,15 @@ def test_multiprocessing(pyfile, target, run, start_method):
@pyfile
def code_to_debug():
import debug_me # noqa
import debuggee
import multiprocessing
import os
import sys
def parent(q, a):
from debug_me import backchannel
from debuggee import backchannel
debuggee.setup()
print("spawning child")
p = multiprocessing.Process(target=child, args=(q, a))
@ -146,7 +148,8 @@ def test_subprocess(pyfile, target, run):
assert "debugpy" in sys.modules
from debug_me import backchannel, debugpy
import debugpy
from debuggee import backchannel
backchannel.send(os.getpid())
backchannel.send(debugpy.__file__)
@ -154,11 +157,12 @@ def test_subprocess(pyfile, target, run):
@pyfile
def parent():
import debug_me # noqa
import debuggee
import os
import subprocess
import sys
debuggee.setup()
argv = [sys.executable, sys.argv[1], "--arg1", "--arg2", "--arg3"]
env = os.environ.copy()
process = subprocess.Popen(
@ -209,8 +213,6 @@ def test_subprocess(pyfile, target, run):
def test_autokill(pyfile, target):
@pyfile
def child():
import debug_me # noqa
while True:
pass
@ -250,8 +252,6 @@ def test_autokill(pyfile, target):
def test_argv_quoting(pyfile, target, run):
@pyfile
def args():
import debug_me # noqa
args = [ # noqa
r"regular",
r"",
@ -267,20 +267,19 @@ def test_argv_quoting(pyfile, target, run):
@pyfile
def parent():
import debug_me # noqa
import debuggee
import sys
import subprocess
from args import args
debuggee.setup()
child = sys.argv[1]
subprocess.check_call([sys.executable] + [child] + args)
@pyfile
def child():
from debug_me import backchannel
import sys
from debuggee import backchannel
from args import args as expected_args
backchannel.send(expected_args)
@ -314,12 +313,13 @@ def test_echo_and_shell(pyfile, target, run):
@pyfile
def code_to_run():
import debug_me # noqa
import debuggee
import sys
import subprocess
import os
debuggee.setup()
if sys.platform == "win32":
args = ["dir", "-c", "."]
else:

View file

@ -19,8 +19,9 @@ from tests.debug import runners
def test_with_no_output(pyfile, target, run):
@pyfile
def code_to_debug():
import debug_me # noqa
import debuggee
debuggee.setup()
() # @wait_for_output
with debug.Session() as session:
@ -42,8 +43,9 @@ def test_with_no_output(pyfile, target, run):
def test_with_tab_in_output(pyfile, target, run):
@pyfile
def code_to_debug():
import debug_me # noqa
import debuggee
debuggee.setup()
a = "\t".join(("Hello", "World"))
print(a)
() # @wait_for_output
@ -65,8 +67,9 @@ def test_with_tab_in_output(pyfile, target, run):
def test_redirect_output(pyfile, target, run, redirect):
@pyfile
def code_to_debug():
import debug_me # noqa
import debuggee
debuggee.setup()
for i in [111, 222, 333, 444]:
print(i)
@ -90,9 +93,10 @@ def test_redirect_output(pyfile, target, run, redirect):
def test_non_ascii_output(pyfile, target, run):
@pyfile
def code_to_debug():
import debug_me # noqa
import debuggee
import sys
debuggee.setup()
a = b"\xc3\xa9 \xc3\xa0 \xc3\xb6 \xc3\xb9\n"
if sys.version_info[0] >= 3:
sys.stdout.buffer.write(a)

View file

@ -19,9 +19,11 @@ def target(request):
def test_with_dot_remote_root(pyfile, long_tmpdir, target, run):
@pyfile
def code_to_debug():
from debug_me import backchannel
import os
import debuggee
from debuggee import backchannel
debuggee.setup()
backchannel.send(os.path.abspath(__file__))
print("done") # @bp
@ -57,10 +59,12 @@ def test_with_dot_remote_root(pyfile, long_tmpdir, target, run):
def test_with_path_mappings(pyfile, long_tmpdir, target, run):
@pyfile
def code_to_debug():
from debug_me import backchannel
import debuggee
import os
import sys
from debuggee import backchannel
debuggee.setup()
backchannel.send(os.path.abspath(__file__))
call_me_back_dir = backchannel.receive()
sys.path.insert(0, call_me_back_dir)

View file

@ -7,7 +7,6 @@ from __future__ import absolute_import, division, print_function, unicode_litera
import os
import pytest
import re
import sys
import time
import debugpy
@ -22,10 +21,13 @@ from tests.patterns import some
def test_run(pyfile, target, run):
@pyfile
def code_to_debug():
from debug_me import backchannel
import os
import sys
import debuggee
from debuggee import backchannel
debuggee.setup()
print("begin")
backchannel.send(os.path.abspath(sys.modules["debugpy"].__file__))
assert backchannel.receive() == "continue"
@ -63,8 +65,10 @@ def test_run_submodule(run):
def test_nodebug(pyfile, run, target):
@pyfile
def code_to_debug():
from debug_me import backchannel
import debuggee
from debuggee import backchannel
debuggee.setup()
backchannel.receive() # @ bp1
print("ok") # @ bp2
@ -103,9 +107,12 @@ def test_wait_on_exit(
):
@pyfile
def code_to_debug():
from debug_me import debugpy
import sys
import debuggee
import debugpy
debuggee.setup()
debugpy.break_into_debugger()
print() # line on which it'll actually break
sys.exit(int(sys.argv[1]))

View file

@ -20,7 +20,9 @@ def run(request):
def test_with_path_mappings(pyfile, tmpdir, target, run):
@pyfile
def code_to_debug():
import debug_me # noqa
import debuggee
debuggee.setup()
def full_function():
# Note that this function is not called, it's there just to make the mapping explicit.

View file

@ -13,7 +13,9 @@ from tests.patterns import some
def test_set_next_statement(pyfile, run, target):
@pyfile
def code_to_debug():
import debug_me # noqa
import debuggee
debuggee.setup()
def func():
print(1) # @inner1

View file

@ -17,7 +17,7 @@ from tests.patterns import some
def test_stop_on_entry(pyfile, run, target, breakpoint):
@pyfile
def code_to_debug():
from debug_me import backchannel # @bp
from debuggee import backchannel # @bp
backchannel.send("done")
@ -31,7 +31,7 @@ def test_stop_on_entry(pyfile, run, target, breakpoint):
if breakpoint:
stop = session.wait_for_stop(
"breakpoint", expected_frames=[some.dap.frame(code_to_debug, 1)]
"breakpoint", expected_frames=[some.dap.frame(code_to_debug, "bp")]
)
session.request("next", {"threadId": stop.thread_id})
stop = session.wait_for_stop(

View file

@ -58,8 +58,10 @@ def expected_system_info():
def test_debugpySystemInfo(pyfile, target, run, expected_system_info):
@pyfile
def code_to_debug():
from debug_me import debugpy
import debuggee
import debugpy
debuggee.setup()
debugpy.break_into_debugger()
print()

View file

@ -15,11 +15,12 @@ from tests import debug
def test_thread_count(pyfile, target, run, count):
@pyfile
def code_to_debug():
import debug_me # noqa
import debuggee
import threading
import time
import sys
debuggee.setup()
stop = False
def worker(tid, offset):
@ -56,9 +57,10 @@ def test_step_multi_threads(pyfile, target, run, resume):
# so, when we step return on thread 1, the program should finish if all threads are resumed
# or should keep waiting for the thread 2 to run if only thread 1 is resumed.
import debug_me # noqa
import debuggee
import threading
debuggee.setup()
event0 = threading.Event()
event1 = threading.Event()
event2 = threading.Event()
@ -135,10 +137,13 @@ def test_step_multi_threads(pyfile, target, run, resume):
def test_debug_this_thread(pyfile, target, run):
@pyfile
def code_to_debug():
from debug_me import debugpy
import debuggee
import debugpy
import sys
import threading
debuggee.setup()
def foo(x):
debugpy.debug_this_thread()
event.set() # @bp

View file

@ -11,9 +11,11 @@ from tests.patterns import some
def test_tracing(pyfile, target, run):
@pyfile
def code_to_debug():
import debug_me # noqa
import debuggee
import debugpy
debuggee.setup()
def func(expected_tracing):
assert debugpy.tracing() == expected_tracing, "inside func({0!r})".format(
expected_tracing

View file

@ -16,9 +16,10 @@ from tests.timeline import Event
def test_stack_format(pyfile, target, run, module, line):
@pyfile
def code_to_debug():
import debug_me # noqa
import debuggee
from test_module import do_something
debuggee.setup()
do_something()
@pyfile
@ -64,7 +65,10 @@ def test_module_events(pyfile, target, run):
@pyfile
def test_code():
import debug_me # noqa
import debuggee
debuggee.setup()
from module1 import do_something
do_something()

View file

@ -1,5 +1,6 @@
import debug_me # noqa
import debuggee
debuggee.setup()
print("one") # @one
print("two") # @two
print("three") # @three

View file

@ -1,8 +1,11 @@
# -*- coding: utf-8 -*-
import sys
import debug_me # noqa
import debuggee
def ಏನದರ_ಮ():
print('ಏನೋ ಮಾಡಿದೆ'.encode(sys.stdout.encoding, errors='replace')) # @bp
debuggee.setup()
ಏನದರ_ಮ()

View file

@ -1,4 +1,6 @@
import debug_me # noqa
import debuggee
debuggee.setup()
import os
import signal

View file

@ -1 +1,3 @@
import debug_me # noqa
import debuggee
debuggee.setup()

View file

@ -1,4 +1,3 @@
import debug_me # noqa
from flask import Flask
from flask import render_template

View file

@ -1,8 +1,9 @@
# For multiproc attach, we need to use a helper stub to import debug_me before running
# For multiproc attach, we need to use a helper stub to import debuggee before running
# Flask; otherwise, we will get the connection only from the subprocess, not from the
# Flask server process.
import debug_me # noqa
import debuggee
import runpy
debuggee.setup()
runpy.run_module("flask", run_name="__main__", alter_sys=True)

View file

@ -1,3 +1,5 @@
from debug_me import backchannel
import debuggee
from debuggee import backchannel
debuggee.setup()
backchannel.send("ok")