debugpy/tests/debugpy/test_justmycode.py
Pavel Minaev 55eac82c96 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.
2020-01-26 17:14:30 -08:00

48 lines
1.4 KiB
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 absolute_import, division, print_function, unicode_literals
import pytest
from tests import debug
from tests.debug import targets
from tests.patterns import some
@pytest.mark.parametrize("jmc", ["jmc", ""])
@pytest.mark.parametrize("target", targets.all_named)
def test_justmycode_frames(pyfile, target, run, jmc):
@pyfile
def code_to_debug():
import debuggee
debuggee.setup()
print("break here") # @bp
with debug.Session() as session:
session.config["justMyCode"] = bool(jmc)
with run(session, target(code_to_debug)):
session.set_breakpoints(code_to_debug, all)
stop = session.wait_for_stop(
"breakpoint", expected_frames=[some.dap.frame(code_to_debug, "bp")]
)
if jmc:
assert len(stop.frames) == 1
else:
assert len(stop.frames) >= 1
session.request("stepIn", {"threadId": stop.thread_id})
if not jmc:
# "stepIn" should stop somewhere inside stdlib
session.wait_for_stop(
"step",
expected_frames=[
some.dap.frame(~some.str.equal_to(code_to_debug), some.int)
],
)
session.request_continue()