MCPcopy Create free account
hub / github.com/microsoft/debugpy / test_exceptions_and_exclude_rules

Function test_exceptions_and_exclude_rules

tests/debugpy/test_exclude_rules.py:24–66  ·  view source on GitHub ↗
(pyfile, target, run, scenario, exc_type)

Source from the content-addressed store, hash-verified

22@pytest.mark.parametrize("scenario", ["exclude_by_name", "exclude_by_dir"])
23@pytest.mark.parametrize("exc_type", ["RuntimeError", "SystemExit"])
24def test_exceptions_and_exclude_rules(pyfile, target, run, scenario, exc_type):
25 if exc_type == "RuntimeError":
26
27 @pyfile
28 def code_to_debug():
29 import debuggee
30
31 debuggee.setup()
32 raise RuntimeError("unhandled error") # @raise_line
33
34 elif exc_type == "SystemExit":
35
36 @pyfile
37 def code_to_debug():
38 import debuggee
39 import sys
40
41 debuggee.setup()
42 sys.exit(1) # @raise_line
43
44 else:
45 pytest.fail(exc_type)
46
47 if scenario == "exclude_by_name":
48 rules = [{"path": "**/" + code_to_debug.basename, "include": False}]
49 elif scenario == "exclude_by_dir":
50 rules = [{"path": code_to_debug.dirname, "include": False}]
51 else:
52 pytest.fail(scenario)
53 log.info("Rules: {0}", json.repr(rules))
54
55 with debug.Session() as session:
56 session.expected_exit_code = some.int
57 session.config["rules"] = rules
58
59 with run(session, target(code_to_debug)):
60 session.request(
61 "setExceptionBreakpoints", {"filters": ["raised", "uncaught"]}
62 )
63
64 # No exceptions should be seen.
65 session.wait_for_next_event("terminated")
66 session.proceed()
67
68
69@pytest.mark.parametrize("scenario", ["exclude_code_to_debug", "exclude_callback_dir"])

Callers

nothing calls this directly

Calls 6

infoMethod · 0.80
wait_for_next_eventMethod · 0.80
proceedMethod · 0.80
runFunction · 0.70
targetFunction · 0.70
requestMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…