Skip to content

Official Codebase of 3DCodeVerse

Python

tests: core, models, agents, prompts — delete duplicates and asserts that measure nothing

gaoypenged1a7db7aad3
diff --git a/harness/tests/agents/test_cli_common.py b/harness/tests/agents/test_cli_common.py
index 60c15fd8..9cc91c73 100644
--- a/harness/tests/agents/test_cli_common.py
+++ b/harness/tests/agents/test_cli_common.py
@@ -174,13 +174,3 @@ def test_mcp_command_resolution(tmp_ws: Workspace):
{"mcpServers": {"3dcode": {"command": "/tmp/evil", "args": ["--pwn"]}}}))
assert mcp_command_for(tmp_ws, job2) == ["python", "-m", "x"]
assert "/tmp/evil" not in mcp_command_for(tmp_ws, job)
-
-
-def test_gemini_system_settings_disable_folder_trust(tmp_path):
- from codeverse3d.agents.backends import write_system_settings
-
- p = write_system_settings(tmp_path / "s.json")
- data = json.loads(p.read_text())
- assert data["security"]["folderTrust"]["enabled"] is False
- assert data["security"]["auth"]["selectedType"] == "gemini-api-key"
- assert data["experimental"]["dynamicModelConfiguration"] is True
diff --git a/harness/tests/agents/test_codex.py b/harness/tests/agents/test_codex.py
index a3e1ad9f..66121050 100644
--- a/harness/tests/agents/test_codex.py
+++ b/harness/tests/agents/test_codex.py
@@ -103,7 +103,7 @@ def test_fake_run(tmp_ws: Workspace, fake_bin, monkeypatch):
a = CodexAgent("gpt-5.6-sol", binary=fake_bin("codex", FAKE_CODEX))
res = a.run(AgentJob(workspace=str(tmp_ws.root), prompt="hello", label="x", timeout_s=30))
assert res.ok and res.exit_reason == "completed" and res.text == "Done." and res.tool_calls == 2, res.errors
- assert [f.path for f in res.files_changed] == ["src/hello.txt"]
+ assert [f.path for f in res.files_changed] == ["src/hello.txt"] and (tmp_ws.src / "hello.txt").read_text() == "hello"
assert res.usage.input_tokens == 1000
# the turn count lands in the TYPED result (one turn.completed event), not only in result.json
assert res.turns == 1 == json.loads((Path(res.transcript_path).parent / "result.json").read_text())["turns"]
@@ -126,12 +126,6 @@ def test_a_codex_failure_is_typed_quota_or_transient(tmp_ws: Workspace, fake_bin
assert not res.ok and res.transient and not res.quota and res.provider_wait_s == 0.0 # codex does not say
-def test_every_prompt_goes_via_stdin(tmp_ws: Workspace, fake_bin):
- a = CodexAgent("gpt-5.6-sol", binary=fake_bin("codex", FAKE_CODEX))
- res = a.run(AgentJob(workspace=str(tmp_ws.root), prompt="hello world", label="z", timeout_s=30))
- assert res.ok and (tmp_ws.src / "hello.txt").read_text() == "hello"
-
-
@pytest.mark.live
def test_live_codex_mcp_tool_call_is_not_cancelled(tmp_ws: Workspace):
"""Regression: without default_tools_approval_mode=approve codex auto-cancels every 3dcode MCP call."""
diff --git a/harness/tests/agents/test_materialize.py b/harness/tests/agents/test_materialize.py
index 69619d7a..f52539dc 100644
--- a/harness/tests/agents/test_materialize.py
+++ b/harness/tests/agents/test_materialize.py
@@ -98,10 +98,8 @@ def test_ignore_files_keep_agent_facing_paths_readable(tmp_ws: Workspace):
assert ignored(hidden, lines), hidden
-def test_spatial_disabled_drops_server_and_documents_absence(tmp_ws: Workspace):
- _mat(tmp_ws)
+def test_spatial_disabled_documents_absence(tmp_ws: Workspace):
_mat(tmp_ws, spatial=False)
- assert "3dcode" not in json.loads((tmp_ws.root / ".gemini" / "settings.json").read_text()).get("mcpServers", {})
assert "No spatial tools are available" in (tmp_ws.root / "AGENTS.md").read_text()
diff --git a/harness/tests/agents/test_tool_trace.py b/harness/tests/agents/test_tool_trace.py
index 3ff2d337..10802591 100644
--- a/harness/tests/agents/test_tool_trace.py
+++ b/harness/tests/agents/test_tool_trace.py
@@ -186,6 +186,8 @@ def test_gemini_system_settings_pin_skills_on_and_keep_the_workspace_trusted(tmp
data = json.loads(write_system_settings(tmp_path / "s.json").read_text())
assert data["skills"]["enabled"] is True and data["skills"] == SYSTEM_SETTINGS["skills"]
assert data["security"]["folderTrust"] == {"enabled": False}
+ assert data["security"]["auth"]["selectedType"] == "gemini-api-key"
+ assert data["experimental"]["dynamicModelConfiguration"] is True # else 0.53 substitutes models
def test_gemini_sessions_see_the_routed_bundles_and_not_the_clis_own(tmp_path):
diff --git a/harness/tests/core/test_events.py b/harness/tests/core/test_events.py
index cf1d64a0..d1b84585 100644
--- a/harness/tests/core/test_events.py
+++ b/harness/tests/core/test_events.py
@@ -16,26 +16,6 @@ from codeverse3d.workspace import Workspace
runner = CliRunner()
-def test_read_skips_a_truncated_last_line(tmp_path: Path) -> None:
- """`emit` writes one buffered line, so a SIGKILL truncates it mid-flush."""
- log = EventLog(tmp_path / "events.jsonl")
- log.emit("round.start", round=0)
- log.emit("build.done", ok=True)
- with log.path.open("a") as fh: # what a SIGKILL leaves behind
- fh.write('{"t": 1756000001.0, "event": "round.start", "rou')
-
- evs = log.read()
-
- assert [e["event"] for e in evs] == ["round.start", "build.done"]
-
-
-def test_read_skips_a_bad_line_in_the_middle_and_undecodable_bytes(tmp_path: Path) -> None:
- p = tmp_path / "events.jsonl"
- p.write_bytes(b'{"event": "a"}\n{"event": "b\xff\n\n{"event": "c"}\n')
-
- assert [e["event"] for e in EventLog(p).read()] == ["a", "c"]
-
-
def test_status_still_prints_the_run_when_events_are_truncated(tmp_path: Path) -> None:
"""The whole status view used to be lost to the last line of the log."""
runs = tmp_path / "runs"
diff --git a/harness/tests/core/test_plan_normalise.py b/harness/tests/core/test_plan_normalise.py
index c2f83073..453a260e 100644
--- a/harness/tests/core/test_plan_normalise.py
+++ b/harness/tests/core/test_plan_normalise.py
@@ -15,16 +15,11 @@ from codeverse3d.tracks.planner import plan_example
def _raw() -> dict:
d = copy.deepcopy(plan_example(Track.ARTICULATED_OBJECT))
- assert ArticulatedPlan.model_validate(d).normalisations == []
+ p = ArticulatedPlan.model_validate(d)
+ assert p.normalisations == [] and [x.name for x in p.parts] == [x["name"] for x in d["parts"]] # a valid plan is untouched
return d
-def test_a_valid_plan_is_untouched():
- d = _raw()
- p = ArticulatedPlan.model_validate(copy.deepcopy(d))
- assert p.normalisations == [] and [x.name for x in p.parts] == [x["name"] for x in d["parts"]]
-
-
def test_a_joint_that_moves_a_sub_part_promotes_it_to_a_link():
d = _raw()
parent = d["parts"][0]
diff --git a/harness/tests/core/test_proc.py b/harness/tests/core/test_proc.py
index 001de884..2eac3e42 100644
--- a/harness/tests/core/test_proc.py
+++ b/harness/tests/core/test_proc.py
@@ -130,18 +130,6 @@ def test_write_json_atomic_round_trips_into_a_new_dir(tmp_path: Path):
assert [q.name for q in p.parent.iterdir()] == ["out.json"]
-def test_workspace_write_json_delegates(tmp_ws):
- from pydantic import BaseModel
-
- class M(BaseModel):
- x: int = 2
-
- p = tmp_ws.root / "artifacts" / "m.json"
- tmp_ws.write_json(p, M())
- assert json.loads(p.read_text()) == {"x": 2}
- assert not p.with_suffix(".json.tmp").exists()
-
-
_WRITER = """
import json, sys
from pathlib import Path
diff --git a/harness/tests/models/test_gemini.py b/harness/tests/models/test_gemini.py
index 6274a0c5..6f69aacb 100644
--- a/harness/tests/models/test_gemini.py
+++ b/harness/tests/models/test_gemini.py
@@ -233,7 +233,6 @@ def test_thinking_rejected_falls_back_without_thinking_config():
assert log[0]["config"].thinking_config is not None and log[1]["config"].thinking_config is None
assert any("thinking" in w for w in r.raw["warnings"])
# sticky for the next call
- m.pool # noqa: B018
log.clear()
m._client_factory = lambda key: FakeClient([text_response("again")], key, log)
m.generate(ChatRequest(messages=[ChatMessage.user("y")]))
@@ -391,8 +390,7 @@ def test_drain_stream_cuts_a_stream_past_its_attempt_budget():
assert e.value.retryable and "attempt budget" in str(e.value)
[email protected](("raw", "streamed"), [(None, True), ("0", False), ("off", False), ("OFF", False),
- ("on", True), ("garbage", True)])
[email protected](("raw", "streamed"), [(None, True), ("off", False)]) # spellings: test_config_env_aliases
def test_streaming_toggle(monkeypatch, switch, raw, streamed):
"""``C3D_STREAM=off`` was silently ignored until 2026-09-22: only "0" was read."""
switch("C3D_STREAM", raw)
@@ -404,7 +402,7 @@ def test_streaming_toggle(monkeypatch, switch, raw, streamed):
assert bool(calls) is streamed
[email protected](("raw", "bound"), [(None, True), ("0", False), ("off", False), ("no", False), ("1", True)])
[email protected](("raw", "bound"), [(None, True), ("off", False)]) # spellings: test_config_env_aliases
def test_ipv4_transport_toggle(switch, raw, bound):
"""``C3D_IPV4=off`` was silently ignored until 2026-09-22: only "0" restored dual-stack."""
import httpx
diff --git a/harness/tests/models/test_retry.py b/harness/tests/models/test_retry.py
index 179b7d37..90456eef 100644
--- a/harness/tests/models/test_retry.py
+++ b/harness/tests/models/test_retry.py
@@ -250,19 +250,6 @@ def test_storm_waits_never_exceed_the_house_limit_at_production_defaults(monkeyp
assert naps and max(naps) == MAX_WAIT_S
-def test_503_storm_budget_exhausts_then_normal_budget_applies():
- """Exhausted storm patience falls back to the finite normal budget."""
- with pytest.raises(ModelError):
- _rotate503(
- _pool(1),
- _boom("503 forever"),
- max_attempts=2,
- base_delay=0.0,
- storm_attempts=3,
- storm_max_delay=0.0,
- )
-
-
def test_one_call_cannot_retry_for_hours():
"""The wall-clock deadline bounds even a long 503 storm."""
clock = Clock()
diff --git a/harness/tests/prompts/test_files.py b/harness/tests/prompts/test_files.py
index 1260ea16..9da95db0 100644
--- a/harness/tests/prompts/test_files.py
+++ b/harness/tests/prompts/test_files.py
@@ -9,7 +9,7 @@ import jinja2
import pytest
from codeverse3d.contracts.common import TRACK_LANGUAGES, Language, Track
-from codeverse3d.prompts import load_text, prompt_hash, render
+from codeverse3d.prompts import load_text, render
from codeverse3d.prompts.catalog import language_prompt
from tests.prompts.conftest import DOC_FILES, PROMPT_FILES, PROMPTS_DIR, is_template, read_prompt
@@ -24,7 +24,6 @@ UNREACHED = {
@pytest.mark.parametrize("rel", PROMPT_FILES)
def test_prompt_file_contract(rel: str) -> None:
raw = load_text(rel)
- assert prompt_hash(raw)
if is_template(rel):
jinja2.Environment().parse(raw) # a template must at least compile
return
@@ -93,10 +92,6 @@ def test_system_prompts_cover_the_laws() -> None:
for needle in ("artifacts/", "render_sheet", "check_connectivity", "2 mm",
"Definition of done", "ground", "seed"):
assert needle.lower() in hc.lower(), f"harness_contract.md must mention {needle!r}"
- # system/tools_usage.md was a hand-written tool list with no production reader
- # (deleted 2026-08-28): the agent's tool section is GENERATED from the @tool
- # registrations by agents/materialize._tool_section, so "every tool is documented"
- # is true by construction and this assertion was checking a file nobody read.
def test_every_language_ships_a_system_prompt_a_contract_and_a_cookbook() -> None:
diff --git a/harness/tests/prompts/test_snippets_static.py b/harness/tests/prompts/test_snippets_static.py
index 6669ddca..f24ee115 100644
--- a/harness/tests/prompts/test_snippets_static.py
+++ b/harness/tests/prompts/test_snippets_static.py
@@ -15,7 +15,6 @@ from tests.prompts.conftest import DOC_FILES, blocks, read_prompt
PY_FILES = [f for f in DOC_FILES if f.split("/")[0] in ("blender", "cadquery", "urdf")]
JS_FILES = [f for f in DOC_FILES if f.split("/")[0] in ("threejs", "scene_threejs")]
-JS_FILES.append("system/singleshot_format.md")
XML_FILES = ["urdf/contract.md", "urdf/cookbook.md"]
@@ -112,7 +111,7 @@ def test_xml_examples_follow_the_enforced_frame_recipe(rel: str, tmp_path) -> No
@pytest.mark.node
[email protected]("rel", [f for f in JS_FILES if f != "system/singleshot_format.md"])
[email protected]("rel", JS_FILES)
def test_js_blocks_syntax(rel: str, tmp_path) -> None:
node = shutil.which("node")
if node is None:
@@ -151,13 +150,13 @@ def test_glsl_strings_are_sane() -> None:
def test_singleshot_example_parses_with_harness_parser() -> None:
- gen = pytest.importorskip("codeverse3d.tracks.generation")
+ from codeverse3d.tracks import generation as gen
+
text = read_prompt("system/singleshot_format.md")
example = blocks("system/singleshot_format.md", "text")[-1]
files = gen.parse_multifile(example)
assert set(files) == {"src/parts/seat.js", "src/object.js"}
assert "buildSeat" in files["src/parts/seat.js"]
assert "=== FILE" not in "".join(files.values())
- assert "SINGLE_SHOT_FORMAT" in dir(gen)
# the format doc and the parser must agree on the markers
assert "=== FILE: " in text and "=== END FILE ===" in text
diff --git a/harness/tests/scene_prompts/test_quality_teaching.py b/harness/tests/scene_prompts/test_quality_teaching.py
index d32f16a3..496ddb9d 100644
--- a/harness/tests/scene_prompts/test_quality_teaching.py
+++ b/harness/tests/scene_prompts/test_quality_teaching.py
@@ -13,33 +13,12 @@ import pytest
from codeverse3d.judges.rubrics import load_rubric
from codeverse3d.prompts import load_text
-#: cookbook chapter titles selected by the scene prompt builder
-QUALITY_CHAPTERS = [
- "Ground that reads real",
- "Horizon: the world must not end",
- "Vegetation that reads real",
- "Rocks, cliffs and boulders that read organic",
- "Set dressing",
- "Scene layering",
- "Atmosphere: time-of-day triads",
- "Motion you can SEE",
- "The exact contract the harness assembler enforces",
-]
-
@pytest.fixture(scope="module")
def cookbook() -> str:
return load_text("scene_threejs/cookbook.md")
[email protected]("title", QUALITY_CHAPTERS)
-def test_cookbook_quality_chapter_is_selectable(cookbook: str, title: str) -> None:
- from codeverse3d.prompts.sections import find_section, split_sections
-
- s = find_section(split_sections(cookbook), title)
- assert s is not None and s.title.startswith(title)
-
-
def test_cookbook_carries_the_numbers_the_recipes_depend_on(cookbook: str) -> None:
for token in ("vertexColors", "setColorAt", "InstancedMesh", "shadow.mapSize",
"cameraMask", "buildHorizonRing", "TIME_OF_DAY", "hazeMix"):