Official Codebase of 3DCodeVerse
Python
tests: flywheel_cli, agents, second pass — five exceptions did not hold (−69 lines)
gaoypenga1fdde3fffdf
diff --git a/harness/tests/agents/test_watchdog.py b/harness/tests/agents/test_watchdog.pyindex bc54d1e2..ab06a1a5 100644--- a/harness/tests/agents/test_watchdog.py+++ b/harness/tests/agents/test_watchdog.py@@ -12,20 +12,6 @@ from codeverse3d.agents.cli_common import run_with_watchdogPY = sys.executable-def test_normal_run_streams_lines_and_delivers_stdin(tmp_path: Path):- """The integration smoke: stdin reaches the child, every line reaches ``on_line``- and the bounded texts, and stdout/stderr stay separate."""- seen = []- res = run_with_watchdog(- [PY, "-c", "import sys; print(sys.stdin.read().upper()); print('b', file=sys.stderr); print('c')"],- cwd=tmp_path, env=None, soft_timeout_s=10, idle_grace_s=5, hard_timeout_s=20,- stdin="hello", on_line=lambda stream, text: seen.append((stream, text)),- )- assert res.rc == 0 and not res.timed_out- assert res.stdout.splitlines() == ["HELLO", "c"]- assert res.stderr.strip() == "b"- assert ("stdout", "HELLO") in seen and ("stderr", "b") in seen-def test_hard_timeout_kills_active_process(tmp_path: Path):code = "import time,sys\nwhile True:\n print('tick'); sys.stdout.flush(); time.sleep(0.2)"diff --git a/harness/tests/flywheel_cli/test_captions.py b/harness/tests/flywheel_cli/test_captions.pyindex 4f90ea3d..6c9cf799 100644--- a/harness/tests/flywheel_cli/test_captions.py+++ b/harness/tests/flywheel_cli/test_captions.py@@ -90,10 +90,8 @@ SHADER = dict(GOOD, instruction="Write a GLSL fragment shader showing neon rain(GOOD, "blender", None),(dict(GOOD, instruction="Please model a wooden chair with four legs for me."), "blender", "target language"),(GOOD_JS, "threejs", None), # the required 'Three.js' phrase is not the forbidden API- (GOOD_JS, "scene_threejs", None),(dict(GOOD_JS, factory="Build a THREE.Group holding THREE.Mesh boxes for every part."), "threejs", "THREE."),(SHADER, "glsl_shader", None),- (dict(SHADER, instruction="Write a shader with rain."), "glsl_shader", "target language"),(dict(SHADER, instruction="Write an OpenGL Python program showing neon rain on a window."), "opengl_python", None),(dict(SHADER, instruction="Write an OpenGL Python program showing neon rain on a window.",factory="Uses moderngl FBOs for the feedback pass."), "opengl_python", "moderngl"),diff --git a/harness/tests/flywheel_cli/test_cli.py b/harness/tests/flywheel_cli/test_cli.pyindex 851d7aac..5d4953ce 100644--- a/harness/tests/flywheel_cli/test_cli.py+++ b/harness/tests/flywheel_cli/test_cli.py@@ -365,21 +365,6 @@ def test_an_unknown_profile_is_a_clean_error_not_a_traceback(tmp_path: Path):assert not (tmp_path / "runs" / "prof").exists(), "no workspace for a rejected flag"-def test_a_negative_budget_is_rejected_before_the_workspace_exists(tmp_path: Path):- """A negative ceiling is rejected before workspace creation."""- runs = tmp_path / "runs"- r = runner.invoke(app, ["make", "a chair", "--max-minutes", "-10", "--no-run",- "--runs-dir", str(runs), "--slug", "neg"])- assert r.exit_code != 0- assert "range x>=0" in r.output.replace("\n", "")- assert not (runs / "neg").exists(), "no workspace may be created for a rejected budget"-- # 0 stays legal (documented: a run at 0 degrades from its first check) ...- r = runner.invoke(app, ["make", "a chair", "--max-minutes", "0", "--no-run",- "--runs-dir", str(runs), "--slug", "zero"])- assert r.exit_code == 0 and (runs / "zero" / "spec.json").is_file()--def test_texture_is_not_offered_on_tracks_that_have_no_glb(tmp_path: Path):"""Impossible explicit texturing fails early; profiles degrade cleanly by track."""from codeverse3d.contracts.common import Trackdiff --git a/harness/tests/flywheel_cli/test_complexity_record.py b/harness/tests/flywheel_cli/test_complexity_record.pyindex c6451cff..2da037f9 100644--- a/harness/tests/flywheel_cli/test_complexity_record.py+++ b/harness/tests/flywheel_cli/test_complexity_record.py@@ -63,8 +63,5 @@ def test_record_carries_the_last_rounds_complexity_and_the_trail() -> None:assert block["parts_per_plan_part"] == pytest.approx(2.0)assert block["by_round"] == [0.42, 0.55]assert [round_summary(r)["complexity"] for r in rec.rounds] == [0.42, 0.55]---def test_complexity_block_falls_back_to_the_last_measured_round() -> None:- rec = _record([_round(0, 0.6, 0.42), _round(1, 0.5, None)])- assert complexity_block(rec)["index"] == 0.42+ # an unmeasured last round falls back to the last measured one+ assert complexity_block(_record([_round(0, 0.6, 0.42), _round(1, 0.5, None)]))["index"] == 0.42diff --git a/harness/tests/flywheel_cli/test_flywheel.py b/harness/tests/flywheel_cli/test_flywheel.pyindex bbcef03a..111cbd42 100644--- a/harness/tests/flywheel_cli/test_flywheel.py+++ b/harness/tests/flywheel_cli/test_flywheel.py@@ -323,26 +323,10 @@ def test_export_includes_textured_assets_when_shipped(fake_run, tmp_path: Path):assert not (sdir2 / "textures").exists()-def test_battery_layouts_are_discovered_by_flywheel_and_gallery(tmp_path):- """All three eval battery layouts resolve runs; eval siblings never become gallery runs."""+def test_an_ab_plan_cell_is_one_run_and_its_eval_sibling_is_none(tmp_path):+ """The ab_plan layout resolves to its run; the compare layout is pinned in gallery/test_index."""from codeverse3d.addons.gallery.index import scan_root- from codeverse3d.record.record import find_run_dirs, iter_runs-- battery = tmp_path / "static_v2_flash" # run_bench: runs/<id>- (battery / "runs" / "some_run").mkdir(parents=True)- (battery / "runs" / "some_run" / "record.json").write_text("{}")- assert [d.name for d in find_run_dirs(battery)] == ["some_run"]-- compare = tmp_path / "compare_v3" # compare_backends: cells/<id>/<arm>/run- for pid in ("p0", "p1"):- for arm in ("harness_codex", "oneshot_gemini"):- run = compare / "cells" / pid / arm / "run"- run.mkdir(parents=True)- (run / "record.json").write_text("{}")- assert len(find_run_dirs(compare)) == 4- invalid: list[str] = []- list(iter_runs(compare, on_error=lambda d, e: invalid.append(d.name)))- assert len(invalid) == 4, "every cell is reached; these stub records are invalid, not absent"+ from codeverse3d.record.record import find_run_dirsab = tmp_path / "ab_aa_noise"cell = ab / "arms" / "control" / "cells" / "ctrl_med_chair" / "harness_api-agent"diff --git a/harness/tests/flywheel_cli/test_gemini_image.py b/harness/tests/flywheel_cli/test_gemini_image.pyindex 8a983cd0..8db1ea4a 100644--- a/harness/tests/flywheel_cli/test_gemini_image.py+++ b/harness/tests/flywheel_cli/test_gemini_image.py@@ -51,16 +51,6 @@ def _model(script: list, used: list[str], sleeps: list[float], *, max_attempts:return m, pool-def test_429_rotation_is_free_while_untried_keys_remain():- used: list[str] = []- sleeps: list[float] = []- script = [ModelError("quota", retryable=True, status=429), _image_response()]- m, _pool = _model(script, used, sleeps, max_attempts=1)- images, _ = m.generate_with_usage("mossy stone tiles")- assert len(images) == 1 and len(used) == 2 and used[0] != used[1]- assert sleeps == [0.5] # courtesy pause only — the attempt budget was not consumed--def test_all_keys_dead_raises_the_key_error():used: list[str] = []sleeps: list[float] = []diff --git a/harness/tests/flywheel_cli/test_manifest_pack.py b/harness/tests/flywheel_cli/test_manifest_pack.pyindex b187edc6..272446c1 100644--- a/harness/tests/flywheel_cli/test_manifest_pack.py+++ b/harness/tests/flywheel_cli/test_manifest_pack.py@@ -3,7 +3,6 @@ byte against it, and publishes archives and index together only after the wholefrom __future__ import annotations-import hashlibimport jsonimport tarfilefrom pathlib import Path@@ -44,14 +43,6 @@ def _tar_member_names(out: Path) -> list[str]:# --------------------------------------------------------------------------- manifest-def test_export_hashes_every_byte_it_wrote(exported_ds: Path):- m = load_manifest(exported_ds)- e = next(x for x in m.entries if x.sample_id == CHAIR_ID)- assert {"meta.json", "captions.json", "code.py", "src/model.py"} <= set(e.files)- for rel, digest in e.files.items():- assert hashlib.sha256((exported_ds / e.sample_rel_dir / rel).read_bytes()).hexdigest() == digest- assert e.code_sha256 != e.code_fingerprint # raw-exact vs normalised-# --------------------------------------------------------------------------- drop-duplicates → packdef test_drop_duplicates_then_pack_ships_no_duplicate(runs_dir: Path, tmp_path: Path):