DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
test: keep dev CI contracts robust to formatting and worker startup
Bingxi Zhao (Frank)80a7dc2b3481
diff --git a/tests/core/test_answer_call_kinds.py b/tests/core/test_answer_call_kinds.pyindex e4151ef9b..43ca71569 100644--- a/tests/core/test_answer_call_kinds.py+++ b/tests/core/test_answer_call_kinds.py@@ -16,6 +16,8 @@ from __future__ import annotationsfrom pathlib import Pathimport re+import pytest+from deeptutor.core.trace import ANSWER_BEARING_CALL_KINDS_REPO_ROOT = Path(__file__).resolve().parents[2]@@ -28,7 +30,7 @@ def _client_answer_call_kinds() -> set[str]:source = _CLIENT_STREAM_TS.read_text(encoding="utf-8")start = source.index("export function shouldAppendEventContent")end = source.index("\n}", start)- return set(re.findall(r'meta\.call_kind === "([a-z_]+)"', source[start:end]))+ return set(re.findall(r'meta\.call_kind\s*===\s*[\'"]([a-z_]+)[\'"]', source[start:end]))def test_client_and_backend_agree_on_which_rounds_carry_the_answer() -> None:@@ -46,3 +48,15 @@ def test_the_chat_loop_only_streams_answers_under_declared_kinds() -> None:used = set(re.findall(r'call_kind="([a-z_]+)"', source))assert used, "expected the chat loop to label its rounds"assert used <= set(ANSWER_BEARING_CALL_KINDS), sorted(used - ANSWER_BEARING_CALL_KINDS)++[email protected]("quote", ["'", '"'])+def test_contract_check_detects_drift_with_either_quote_style(tmp_path, monkeypatch, quote):+ source = _CLIENT_STREAM_TS.read_text(encoding="utf-8")+ source = source.replace("'", quote).replace('"', quote)+ source = source.replace("llm_final_response", "unexpected_answer_kind")+ fixture = tmp_path / "stream.ts"+ fixture.write_text(source, encoding="utf-8")+ monkeypatch.setattr(f"{__name__}._CLIENT_STREAM_TS", fixture)+ assert "unexpected_answer_kind" in _client_answer_call_kinds()+ assert _client_answer_call_kinds() != set(ANSWER_BEARING_CALL_KINDS)diff --git a/tests/runtime/test_native_engine.py b/tests/runtime/test_native_engine.pyindex 19f2f3e2e..fdf9f437c 100644--- a/tests/runtime/test_native_engine.py+++ b/tests/runtime/test_native_engine.py@@ -231,7 +231,8 @@ async def test_native_cancel_and_worker_loss_never_replay(native):task = asyncio.create_task(native.client.run_native(Port(), payload(native.endpoint, "stall-fixture")))- await asyncio.wait_for(native.entered.wait(), 2)+ # Cold worker startup is not the cancellation deadline; allow CI process scheduling.+ await asyncio.wait_for(native.entered.wait(), 10)native.client._process.kill()with pytest.raises(LLMProviderTransportError) as raised:await asyncio.wait_for(task, 2)@@ -241,7 +242,8 @@ async def test_native_cancel_and_worker_loss_never_replay(native):task = asyncio.create_task(native.client.run_native(Port(), payload(native.endpoint, "stall-fixture")))- await asyncio.wait_for(native.entered.wait(), 2)+ # Cold worker startup is not the cancellation deadline; allow CI process scheduling.+ await asyncio.wait_for(native.entered.wait(), 10)task.cancel()with pytest.raises(asyncio.CancelledError):await task