Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only use "sysmon" core when available (Python 3.12 ) #1747

Merged
merged 2 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions coverage/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 150,10 @@ def __init__(
core = "pytrace"
else:
core = os.getenv("COVERAGE_CORE")

if core == "sysmon" and not env.PYBEHAVIOR.pep669:
core = None

if not core:
# Once we're comfortable with sysmon as a default:
# if env.PYBEHAVIOR.pep669 and self.should_start_context is None:
Expand Down
6 changes: 4 additions & 2 deletions tests/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -1122,15 1122,17 @@ def test_core_request_pytrace(self) -> None:
core = re_line(r" core:", out).strip()
assert core == "core: PyTracer"

@pytest.mark.skipif(not env.PYBEHAVIOR.pep669, reason="No sys.monitoring to request")
def test_core_request_sysmon(self) -> None:
self.del_environ("COVERAGE_TEST_CORES")
self.set_environ("COVERAGE_CORE", "sysmon")
self.make_file("numbers.py", "print(123, 456)")
out = self.run_command("coverage run --debug=sys numbers.py")
assert out.endswith("123 456\n")
core = re_line(r" core:", out).strip()
assert core == "core: SysMonitor"
if env.PYBEHAVIOR.pep669:
assert core == "core: SysMonitor"
else:
assert core in ("core: CTracer", "core: PyTracer")


class FailUnderNoFilesTest(CoverageTest):
Expand Down
Loading