Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

test: isolate CI timing assertions from unrelated work (#7972)

LearningCircuit26e6f279a5f3
diff --git a/tests/security/test_ooxml_decompression_caps.py b/tests/security/test_ooxml_decompression_caps.py
index 567deff943..9afc81a0c4 100644
--- a/tests/security/test_ooxml_decompression_caps.py
+++ b/tests/security/test_ooxml_decompression_caps.py
@@ -8795,10 +8795,15 @@ class TestXlsxListCeilings:
guard.validate_zip_container(
_xlsx_with_workbook(change), ".xlsx"
)
- start = time.perf_counter()
+ # Measure validation alone: workbook creation and compression are
+ # fixture setup. Calling-thread CPU time excludes runner scheduling
+ # delays and unrelated background threads without relaxing the cap.
+ data = extra(1_000_000)
+ start = time.thread_time()
with pytest.raises(guard.DecompressionBombError):
- guard.validate_zip_container(extra(1_000_000), ".xlsx")
- assert time.perf_counter() - start < 5
+ guard.validate_zip_container(data, ".xlsx")
+ elapsed = time.thread_time() - start
+ assert elapsed < 5, f"workbook validation used {elapsed:.2f}s of CPU"
def test_excel_like_workbook_passes(self):
"""Excel writes repeated children inside its calculation-feature
diff --git a/tests/text_optimization/test_citation_formatter_contracts.py b/tests/text_optimization/test_citation_formatter_contracts.py
index 85865f40b3..1ed3fc7eb9 100644
--- a/tests/text_optimization/test_citation_formatter_contracts.py
+++ b/tests/text_optimization/test_citation_formatter_contracts.py
@@ -981,6 +981,10 @@ class TestRegexBounds:
Inputs are deliberately small (10-40 KB). The formerly quadratic
parsers take seconds at these sizes, while a linear implementation
stays comfortably within the bounds below.
+
+ These synchronous scans use calling-thread CPU time so scheduling
+ delays and unrelated background threads do not consume their budgets.
+ The global pytest timeout still bounds wall time.
"""
def test_pathological_bracket_input_stays_fast(self):
@@ -997,9 +1001,9 @@ class TestRegexBounds:
)
formatter = CitationFormatter(CitationMode.DOMAIN_HYPERLINKS)
for chunk in pathological:
- started = time.perf_counter()
+ started = time.thread_time()
formatter.format_document(make_doc(chunk, sources))
- elapsed = time.perf_counter() - started
+ elapsed = time.thread_time() - started
assert elapsed < 2.0, f"input {chunk[:24]!r}... took {elapsed:.2f}s"
def test_ris_author_split_is_not_quadratic_in_whitespace(self):
@@ -1007,9 +1011,9 @@ class TestRegexBounds:
sources_block = (
f"## Sources\n\n[1] Study by A{run}B.\nURL: https://x.example/p\n"
)
- started = time.perf_counter()
+ started = time.thread_time()
RISExporter().export_to_ris(sources_block)
- elapsed = time.perf_counter() - started
+ elapsed = time.thread_time() - started
# A linear split handles 10 KB in well under a millisecond; the
# 0.25s budget leaves ~6x headroom over the measured 1.6s so a
# fast machine cannot XPASS this by accident.
@@ -1053,9 +1057,9 @@ class TestRegexBounds:
+ title.format(run=run)
+ "\nURL: https://x.example/p\n"
)
- started = time.process_time()
+ started = time.thread_time()
RISExporter().export_to_ris(sources_block)
- elapsed = time.process_time() - started
+ elapsed = time.thread_time() - started
# Linear cleanup takes a few milliseconds here. Each of the four
# former ``\s*``-led substitutions took about 2s at 20k.
assert elapsed < 0.25, (
@@ -1085,9 +1089,9 @@ class TestRegexBounds:
)
def test_quarto_cell_fence_scan_is_not_quadratic_in_spaces(self, line):
body = "# Report\n\n" + line.replace("RUN", " " * 10000) + "\n\nText.\n"
- started = time.process_time()
+ started = time.thread_time()
QuartoExporter().export_to_quarto(body, "Report")
- elapsed = time.process_time() - started
+ elapsed = time.thread_time() - started
# The former `` *[ ,].*`` options group took 2.5-3.5s here.
assert elapsed < 0.25, (
f"cell-fence scan took {elapsed:.2f}s on a 10KB run of spaces"
@@ -1112,9 +1116,9 @@ class TestRegexBounds:
# the former re-read-until-stable loop needed one full pass per
# cell: 8000 cells took 20-50s.
body = "# Report\n\n" + unit * 8000 + "\nText.\n"
- started = time.process_time()
+ started = time.thread_time()
output = QuartoExporter().export_to_quarto(body, "Report")
- elapsed = time.process_time() - started
+ elapsed = time.thread_time() - started
assert "{a}" not in output
assert "{r" not in output
assert "{python" not in output
@@ -2089,9 +2093,9 @@ class TestRegexBounds:
)
def test_quarto_body_defusion_is_a_linear_fixed_point(self, unit):
body = unit * 50000
- started = time.process_time()
+ started = time.thread_time()
once = self._qmd_body(body)[1]
- elapsed = time.process_time() - started
+ elapsed = time.thread_time() - started
assert elapsed < 1.0, f"body defusion took {elapsed:.2f}s"
assert self._qmd_body(once)[1] == once
@@ -2110,9 +2114,9 @@ class TestRegexBounds:
"""Each ``&`` reads up to the next ``;`` (Pandoc's
``characterReference``); re-reading that span per ``&`` would be
quadratic in a run of them."""
- started = time.process_time()
+ started = time.thread_time()
_defuse_quarto_body(body)
- elapsed = time.process_time() - started
+ elapsed = time.thread_time() - started
assert elapsed < 1.0, f"entity scan took {elapsed:.2f}s"
def test_collection_line_scan_is_not_quadratic_in_blank_lines(self):
@@ -2120,9 +2124,9 @@ class TestRegexBounds:
"[1] Title\nURL: https://x.example\n" + "\n" * 24000 + "end\n"
)
formatter = CitationFormatter(CitationMode.SOURCE_TAGGED_HYPERLINKS)
- started = time.perf_counter()
+ started = time.thread_time()
collections = formatter._parse_collections(sources_block)
- elapsed = time.perf_counter() - started
+ elapsed = time.thread_time() - started
assert collections == {}
assert elapsed < 0.1, (
f"collection scan took {elapsed:.2f}s on 24k blank lines"