From 9d3bc7631b652cb4dc3803d866aee271e1cf3ea4 Mon Sep 17 00:00:00 2001 From: mhucka Date: Sat, 29 Nov 2025 02:57:54 +0000 Subject: [PATCH 1/2] Add pytest-cov sysmon flag to pyprompt.toml As of mid-2025, this feature is available in Python 3.12 and higher, and is reported to help speed up coverage tests. --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index ce10a28c52f..71c38b52150 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,6 +19,9 @@ include = [ ] omit = ["benchmarks/*"] patch = ["subprocess"] +# Speed up pytest-cov on Python 3.12+ by enabling sys.monitoring if possible. +core = "sysmon" +disable_warnings = ["no-sysmon"] [tool.coverage.report] exclude_also = [ From 03d147e86d1539243ff53abb8c87422767ba5982 Mon Sep 17 00:00:00 2001 From: mhucka Date: Sat, 29 Nov 2025 03:41:10 +0000 Subject: [PATCH 2/2] Be more selective in directories tested for coverage By changing `include` and `omit` values for `tool.coverage.run`, we can limit the files that pytest-cov scans to look foir tests and thereby gain a slight speedup. (I'm seeing 5% faster times on a Linux system when running with `-n 32`.) --- pyproject.toml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 71c38b52150..25d54e95200 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,12 +12,13 @@ extend-exclude = ".*_pb2[.]py[i]?" [tool.coverage.run] include = [ - # Omit files outside the current working directory. + # Include only the directories that have pytest tests in them. # Note: this means coverage must be run from the cirq repo root. # Failure to do so will result in false positives. - "./*", + "./cirq-*", + "./dev_tools/*", + "./examples/*", ] -omit = ["benchmarks/*"] patch = ["subprocess"] # Speed up pytest-cov on Python 3.12+ by enabling sys.monitoring if possible. core = "sysmon"