diff --git a/tests/__init__.py b/tests/__init__.py index 7aed1475..d22af475 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -7,12 +7,14 @@ from __future__ import absolute_import, division, print_function, unicode_litera """debugpy tests """ +import os import pkgutil import py import pytest # Do not import anything from debugpy until assert rewriting is enabled below! +full = int(os.environ.get("DEBUGPY_TESTS_FULL", "0")) != 0 root = py.path.local(__file__) / ".." diff --git a/tests/debugpy/test_breakpoints.py b/tests/debugpy/test_breakpoints.py index bc0352b8..1f8113b5 100644 --- a/tests/debugpy/test_breakpoints.py +++ b/tests/debugpy/test_breakpoints.py @@ -10,6 +10,7 @@ import re import sys from debugpy.common import fmt +import tests from tests import debug, test_data from tests.debug import runners, targets from tests.patterns import some @@ -17,9 +18,10 @@ from tests.patterns import some bp_root = test_data / "bp" -@pytest.fixture(params=[runners.launch, runners.attach_listen["api"]]) -def run(request): - return request.param +if not tests.full: + @pytest.fixture(params=[runners.launch, runners.attach_connect["cli"]]) + def run(request): + return request.param @pytest.mark.parametrize("target", targets.all_named) @@ -171,13 +173,14 @@ def test_error_in_condition(pyfile, target, run, error_name): }, ) - assert not session.captured_stdout() + if "internalConsole" not in str(run): + assert not session.captured_stdout() - error_name = error_name.encode("ascii") - if expect_traceback: - assert error_name in session.captured_stderr() - else: - assert error_name not in session.captured_stderr() + error_name = error_name.encode("ascii") + if expect_traceback: + assert error_name in session.captured_stderr() + else: + assert error_name not in session.captured_stderr() @pytest.mark.parametrize("condition", ["condition", ""]) @@ -230,7 +233,8 @@ def test_log_point(pyfile, target, run, condition): # print() should produce both actual output, and "output" events on stderr, # but logpoints should only produce "output" events on stdout. - assert not session.captured_stdout() + if "internalConsole" not in str(run): + assert not session.captured_stdout() expected_stdout = "".join( (fmt(r"{0}\r?\n", re.escape(str(i))) for i in range(0, 10)) diff --git a/tests/debugpy/test_exclude_rules.py b/tests/debugpy/test_exclude_rules.py index 2d6f9ba9..5b60cfc7 100644 --- a/tests/debugpy/test_exclude_rules.py +++ b/tests/debugpy/test_exclude_rules.py @@ -6,14 +6,16 @@ from __future__ import absolute_import, division, print_function, unicode_litera import pytest +import tests from tests import code, debug, log, test_data from tests.debug import targets from tests.patterns import some -@pytest.fixture(params=targets.all_named) -def target(request): - return request.param +if not tests.full: + @pytest.fixture(params=targets.all_named) + def target(request): + return request.param @pytest.mark.parametrize("scenario", ["exclude_by_name", "exclude_by_dir"]) diff --git a/tests/debugpy/test_gevent.py b/tests/debugpy/test_gevent.py index 4026354c..52f7cb21 100644 --- a/tests/debugpy/test_gevent.py +++ b/tests/debugpy/test_gevent.py @@ -60,7 +60,7 @@ def test_gevent(pyfile, target, run): with debug.Session() as session: session.config["gevent"] = True - if str(run) == "listen(cli)" or str(run) == "connect(cli)": + if str(run).startswith("attach"): session.spawn_debuggee.env["GEVENT_SUPPORT"] = "True" with run(session, target(code_to_debug)): diff --git a/tests/debugpy/test_justmycode.py b/tests/debugpy/test_justmycode.py index 484620ef..0ff6d9b6 100644 --- a/tests/debugpy/test_justmycode.py +++ b/tests/debugpy/test_justmycode.py @@ -19,7 +19,9 @@ def test_justmycode_frames(pyfile, target, run, jmc): import debuggee debuggee.setup() - print("break here") # @bp + + import this # @bp + assert this with debug.Session() as session: session.config["justMyCode"] = bool(jmc) @@ -37,12 +39,14 @@ def test_justmycode_frames(pyfile, target, run, jmc): session.request("stepIn", {"threadId": stop.thread_id}) + # With JMC, it should step out of the function, remaining in the same file. + # Without JMC, it should step into stdlib. + expected_path = some.path(code_to_debug) 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() + expected_path = ~expected_path + session.wait_for_stop( + "step", + expected_frames=[some.dap.frame(some.dap.source(expected_path), some.int)], + ) + + session.request_continue() diff --git a/tests/debugpy/test_multiproc.py b/tests/debugpy/test_multiproc.py index 53e66573..4148cc13 100644 --- a/tests/debugpy/test_multiproc.py +++ b/tests/debugpy/test_multiproc.py @@ -8,14 +8,16 @@ import pytest import sys import debugpy +import tests from tests import debug from tests.debug import runners from tests.patterns import some -@pytest.fixture(params=[runners.launch] + runners.all_attach_socket) -def run(request): - return request.param +if not tests.full: + @pytest.fixture(params=[runners.launch] + runners.all_attach_socket) + def run(request): + return request.param @pytest.mark.parametrize( diff --git a/tests/debugpy/test_path_mapping.py b/tests/debugpy/test_path_mapping.py index 8d635014..d3b7b9e0 100644 --- a/tests/debugpy/test_path_mapping.py +++ b/tests/debugpy/test_path_mapping.py @@ -6,14 +6,16 @@ from __future__ import absolute_import, division, print_function, unicode_litera import pytest +import tests from tests import debug, test_data from tests.debug import targets from tests.patterns import some -@pytest.fixture(params=targets.all_named) -def target(request): - return request.param +if not tests.full: + @pytest.fixture(params=targets.all_named) + def target(request): + return request.param def test_with_dot_remote_root(pyfile, long_tmpdir, target, run): diff --git a/tests/debugpy/test_source_mapping.py b/tests/debugpy/test_source_mapping.py index b7f2feb4..b8f76647 100644 --- a/tests/debugpy/test_source_mapping.py +++ b/tests/debugpy/test_source_mapping.py @@ -7,14 +7,16 @@ from __future__ import absolute_import, division, print_function, unicode_litera import pytest import sys +import tests from tests import debug from tests.debug import runners from tests.patterns import some -@pytest.fixture(params=[runners.launch, runners.attach_listen["api"]]) -def run(request): - return request.param +if not tests.full: + @pytest.fixture(params=[runners.launch, runners.attach_listen["api"]]) + def run(request): + return request.param def test_with_path_mappings(pyfile, tmpdir, target, run): diff --git a/tests/pytest_fixtures.py b/tests/pytest_fixtures.py index db3f2f89..1baef1ad 100644 --- a/tests/pytest_fixtures.py +++ b/tests/pytest_fixtures.py @@ -13,12 +13,13 @@ import threading import types from debugpy.common import compat, fmt, log, timestamp +import tests from tests import code, logs from tests.debug import runners, session, targets # Set up the test matrix for various code types and attach methods -if int(os.environ.get("DEBUGPY_TESTS_FULL", "0")): +if tests.full: TARGETS = targets.all_named RUNNERS = runners.all_launch + runners.all_attach_socket else: diff --git a/tox.ini b/tox.ini index 1899807b..a27a621a 100644 --- a/tox.ini +++ b/tox.ini @@ -3,7 +3,7 @@ envlist = py{27,35,36,37,38}{,-cov} [testenv] deps = -rtests/requirements.txt -passenv = DEBUGPY_LOG_DIR TRAVIS +passenv = DEBUGPY_LOG_DIR DEBUGPY_TESTS_FULL TRAVIS setenv = DEBUGPY_TEST=1 commands =