mirror of
https://github.com/microsoft/debugpy.git
synced 2025-12-23 08:48:12 +00:00
Pull in pydevd sys.monitoring support (#1680)
This is pulling in @fabioz's latest changes for sys.monitoring and then fixing up any issues found with the debugpy tests. A lot of the changes were made by Fabio since the latest pull from pydevd, so I also created this PR to compare what changes I made to Fabio's baseline: rchiodo/PyDev.Debugger#1 Meaning you really only need to look at that other PR to see what changes I made. The rest of the changes here are from Fabio or ruff doing reformating. After this goes through, we should have sys.monitoring support in debugpy. We can decide later if we want to implement our own support as @int19h started. Fixes #1496
This commit is contained in:
parent
a2f80817a1
commit
ae6812bdac
337 changed files with 130307 additions and 56099 deletions
17
tests/_logs/test-logs.code-workspace
Normal file
17
tests/_logs/test-logs.code-workspace
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "3.12-64/tests/debugpy/test_django.py/test_django_template_exception_no_multiproc[launch]"
|
||||
},
|
||||
{
|
||||
"path": "../../../debugpy-2/tests/_logs/3.11-64/tests/debugpy/test_django.py/test_django_template_exception_no_multiproc[launch]"
|
||||
},
|
||||
{
|
||||
"path": "3.12-64/tests/debugpy/test_exception.py/test_systemexit[0-zero-uncaught-raised-launch(console=internalConsole)-program]"
|
||||
},
|
||||
{
|
||||
"path": "3.12-64/tests/debugpy/test_exception.py/test_systemexit[1-zero-uncaught--launch(console=externalTerminal)-module]"
|
||||
}
|
||||
],
|
||||
"settings": {}
|
||||
}
|
||||
|
|
@ -4,12 +4,26 @@
|
|||
|
||||
import io
|
||||
import os
|
||||
import pytest_timeout
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
from debugpy.common import json, log
|
||||
|
||||
|
||||
def write_title(title, stream=None, sep="~"):
|
||||
"""Write a section title.
|
||||
If *stream* is None sys.stderr will be used, *sep* is used to
|
||||
draw the line.
|
||||
"""
|
||||
if stream is None:
|
||||
stream = sys.stderr
|
||||
width, height = shutil.get_terminal_size()
|
||||
fill = int((width - len(title) - 2) / 2)
|
||||
line = " ".join([sep * fill, title, sep * fill])
|
||||
if len(line) < width:
|
||||
line += sep * (width - len(line))
|
||||
stream.write("\n" + line + "\n")
|
||||
|
||||
def dump():
|
||||
if log.log_dir is None:
|
||||
return
|
||||
|
|
@ -27,5 +41,5 @@ def dump():
|
|||
pass
|
||||
else:
|
||||
path = os.path.relpath(path, log.log_dir)
|
||||
pytest_timeout.write_title(path)
|
||||
write_title(path)
|
||||
print(s, file=sys.stderr)
|
||||
|
|
|
|||
|
|
@ -99,10 +99,11 @@ def test_wrapper(request, long_tmpdir):
|
|||
|
||||
finally:
|
||||
if not failed and not request.config.option.debugpy_log_passed:
|
||||
try:
|
||||
py.path.local(log.log_dir).remove()
|
||||
except Exception:
|
||||
pass
|
||||
# try:
|
||||
# py.path.local(log.log_dir).remove()
|
||||
# except Exception:
|
||||
# pass
|
||||
pass
|
||||
log.log_dir = original_log_dir
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import pytest
|
|||
import pytest_timeout
|
||||
import sys
|
||||
|
||||
from debugpy.common import log
|
||||
from debugpy.common import log # pyright: ignore[reportAttributeAccessIssue]
|
||||
import tests
|
||||
from tests import logs
|
||||
|
||||
|
|
@ -56,9 +56,8 @@ def pytest_runtest_makereport(item, call):
|
|||
def pytest_make_parametrize_id(config, val):
|
||||
return getattr(val, "pytest_id", None)
|
||||
|
||||
|
||||
# If a test times out and pytest tries to print the stacks of where it was hanging,
|
||||
# we want to print the pydevd log as well. This is not a normal pytest hook - we
|
||||
# just detour pytest_timeout.dump_stacks directly.
|
||||
_dump_stacks = pytest_timeout.dump_stacks
|
||||
pytest_timeout.dump_stacks = lambda: (_dump_stacks(), logs.dump())
|
||||
pytest_timeout.dump_stacks = lambda terminal: (_dump_stacks(terminal), logs.dump())
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ pytest-retry
|
|||
|
||||
importlib_metadata
|
||||
psutil
|
||||
untangle
|
||||
|
||||
## Used in Python code that is run/debugged by the tests:
|
||||
|
||||
|
|
@ -18,3 +19,4 @@ flask
|
|||
gevent
|
||||
numpy
|
||||
requests
|
||||
typing_extensions
|
||||
Loading…
Add table
Add a link
Reference in a new issue