Skip to content

Official Codebase of 3DCodeVerse

Python

tests: drop the no-op './lib/' rewrites — run_node_json already resolves ./lib/ to runtime_js/lib

gaoypengdff88634ee7a
diff --git a/harness/tests/scene_runtime/test_camera_inside_volume.py b/harness/tests/scene_runtime/test_camera_inside_volume.py
index cbcc2002..79207062 100644
--- a/harness/tests/scene_runtime/test_camera_inside_volume.py
+++ b/harness/tests/scene_runtime/test_camera_inside_volume.py
@@ -11,12 +11,10 @@ from __future__ import annotations
import pytest
-from codeverse3d.config import get_settings
from tests.scene_runtime.conftest import needs_node, run_node_json
pytestmark = [pytest.mark.node, needs_node]
-RUNTIME_JS = get_settings().runtime_js_dir()
JS = """
import * as THREE from 'three';
@@ -71,7 +69,7 @@ head.name = 'HeadlandTerrain'; head.rotation.x = -Math.PI / 2; head.position.y =
def _run(body: str, eye: str, look_at: str = "null") -> dict:
- return run_node_json(JS.replace("BODY", body).replace("EYE", eye).replace("LOOKAT", look_at).replace("'./lib/", f"'{RUNTIME_JS}/lib/"))
+ return run_node_json(JS.replace("BODY", body).replace("EYE", eye).replace("LOOKAT", look_at))
def test_a_lens_near_lattice_sails_is_not_inside_them():
@@ -105,15 +103,13 @@ def test_the_ground_under_the_lens_is_the_ray_straight_down_not_the_highest_grou
def test_a_surface_filling_the_lens_counts_its_near_sight_rays():
JS_PILLAR = JS.replace("cam.lookAt(0, 8, 0);", "cam.lookAt(0, 1.6, -10);")
- got = run_node_json(JS_PILLAR.replace("BODY", PILLAR).replace("EYE", "0, 1.6, 0").replace("LOOKAT", "[0, 1.6, -4]")
- .replace("'./lib/", f"'{RUNTIME_JS}/lib/"))
+ got = run_node_json(JS_PILLAR.replace("BODY", PILLAR).replace("EYE", "0, 1.6, 0").replace("LOOKAT", "[0, 1.6, -4]"))
assert got["near_rays"] >= 6 and got["near_limit_m"] == 1.5 and got["nearest_hit_name"] == "StonePillar_3", got
assert got["camera_in_geometry"] is False, got # 0.8 m away is not "inside": a different verdict
# the line of sight to a subject 4 m away is cut by the pillar at 0.8 m
assert abs(got["target_distance_m"] - 4.0) < 1e-3 and abs(got["target_hit_m"] - 0.8) < 1e-3, got
assert got["target_hit_name"] == "StonePillar_3", got
- clear = run_node_json(JS_PILLAR.replace("BODY", "").replace("EYE", "0, 1.6, 0").replace("LOOKAT", "[0, 1.6, -4]")
- .replace("'./lib/", f"'{RUNTIME_JS}/lib/"))
+ clear = run_node_json(JS_PILLAR.replace("BODY", "").replace("EYE", "0, 1.6, 0").replace("LOOKAT", "[0, 1.6, -4]"))
assert clear["near_rays"] == 0 and clear["target_hit_m"] is None, clear
diff --git a/harness/tests/scene_runtime/test_camera_repair.py b/harness/tests/scene_runtime/test_camera_repair.py
index 74ec62ce..bb3c8a2c 100644
--- a/harness/tests/scene_runtime/test_camera_repair.py
+++ b/harness/tests/scene_runtime/test_camera_repair.py
@@ -4,12 +4,10 @@ from __future__ import annotations
import pytest
-from codeverse3d.config import get_settings
from tests.scene_runtime.conftest import needs_node, run_node_json
pytestmark = [pytest.mark.node, needs_node]
-RUNTIME_JS = get_settings().runtime_js_dir()
JS = """
import * as THREE from 'three';
@@ -56,7 +54,7 @@ console.log(JSON.stringify({ fix, after, noFix, lifted, liftedAfter, stepped, st
@pytest.fixture(scope="module")
def result() -> dict:
- return run_node_json(JS.replace("'./lib/", f"'{RUNTIME_JS}/lib/"))
+ return run_node_json(JS)
def test_a_lens_inside_geometry_retreats_until_clear(result):
diff --git a/harness/tests/scene_runtime/test_camera_volumetric.py b/harness/tests/scene_runtime/test_camera_volumetric.py
index 2f2e0e00..10f284fb 100644
--- a/harness/tests/scene_runtime/test_camera_volumetric.py
+++ b/harness/tests/scene_runtime/test_camera_volumetric.py
@@ -18,12 +18,10 @@ from __future__ import annotations
import pytest
-from codeverse3d.config import get_settings
from tests.scene_runtime.conftest import needs_node, run_node_json
pytestmark = [pytest.mark.node, needs_node]
-RUNTIME_JS = get_settings().runtime_js_dir()
JS = """
import * as THREE from 'three';
@@ -51,7 +49,7 @@ console.log(JSON.stringify(nearGeometry(scene, cam, THREE)));
def _run(depth_write: str) -> dict:
- return run_node_json(JS.replace("DEPTH_WRITE", depth_write).replace("'./lib/", f"'{RUNTIME_JS}/lib/"))
+ return run_node_json(JS.replace("DEPTH_WRITE", depth_write))
@pytest.fixture(scope="module")
@@ -113,12 +111,12 @@ def test_a_camera_standing_in_a_moonbeam_is_not_retreated():
ArmchairHearthEye and WindowFrostSnow were each moved back 4 m and up 2 m because
they stood in a `MoonlightShaft`, and the first of those ended NEARER geometry than
it started (2.358 m -> 0.916 m). The judge then scored a shot nobody asked for."""
- out = run_node_json(REPAIR_JS.replace("DEPTH_WRITE", "false").replace("'./lib/", f"'{RUNTIME_JS}/lib/"))
+ out = run_node_json(REPAIR_JS.replace("DEPTH_WRITE", "false"))
assert out["fix"] in (None, False), "standing in a light shaft is the shot, not a defect"
def test_a_camera_buried_in_a_solid_slab_is_still_retreated():
"""The control: the same geometry that writes depth is matter, and the lens moves."""
- out = run_node_json(REPAIR_JS.replace("DEPTH_WRITE", "true").replace("'./lib/", f"'{RUNTIME_JS}/lib/"))
+ out = run_node_json(REPAIR_JS.replace("DEPTH_WRITE", "true"))
assert out["fix"], "a lens inside a solid slab must still be repaired"
diff --git a/harness/tests/scene_runtime/test_census_stamps.py b/harness/tests/scene_runtime/test_census_stamps.py
index 6dccd040..b7ec58e0 100644
--- a/harness/tests/scene_runtime/test_census_stamps.py
+++ b/harness/tests/scene_runtime/test_census_stamps.py
@@ -5,12 +5,10 @@ from __future__ import annotations
import pytest
-from codeverse3d.config import get_settings
from tests.scene_runtime.conftest import needs_node, run_node_json
pytestmark = [pytest.mark.node, needs_node]
-RUNTIME_JS = get_settings().runtime_js_dir()
JS = """
import * as THREE from 'three';
@@ -40,7 +38,7 @@ console.log(JSON.stringify(g.stamps));
def _stamps(jitter: float) -> dict[str, dict]:
- rows = run_node_json(JS.replace("JITTER", repr(jitter)).replace("'./lib/", f"'{RUNTIME_JS}/lib/"))
+ rows = run_node_json(JS.replace("JITTER", repr(jitter)))
return {r["name"]: r for r in rows}
diff --git a/harness/tests/scene_runtime/test_placement_census.py b/harness/tests/scene_runtime/test_placement_census.py
index 502c0a76..4a8800dd 100644
--- a/harness/tests/scene_runtime/test_placement_census.py
+++ b/harness/tests/scene_runtime/test_placement_census.py
@@ -4,12 +4,10 @@ from __future__ import annotations
import pytest
-from codeverse3d.config import get_settings
from tests.scene_runtime.conftest import needs_node, run_node_json
pytestmark = [pytest.mark.node, needs_node]
-RUNTIME_JS = get_settings().runtime_js_dir()
SCENE_JS = """
import * as THREE from 'three';
@@ -49,7 +47,7 @@ console.log(JSON.stringify({ ground_y: c.ground_y, placement: c.placement, plain
@pytest.fixture(scope="module")
def table() -> dict:
- out = run_node_json(SCENE_JS.replace("'./lib/", f"'{RUNTIME_JS}/lib/"))
+ out = run_node_json(SCENE_JS)
assert out["ground_y"] == 0 and out["plain_has_placement"] is False # the render-time census stays cheap
return out["placement"]
@@ -134,7 +132,7 @@ console.log(JSON.stringify({ settle, after: { assets: after.assets.map((a) => ({
@pytest.fixture(scope="module")
def settled() -> dict:
- return run_node_json(SETTLE_JS.replace("'./lib/", f"'{RUNTIME_JS}/lib/"))
+ return run_node_json(SETTLE_JS)
def test_settle_seats_floating_and_sunken_and_reports_the_moves(settled):
diff --git a/harness/tests/scene_runtime/test_placement_volumetric.py b/harness/tests/scene_runtime/test_placement_volumetric.py
index eaf29087..1984a96f 100644
--- a/harness/tests/scene_runtime/test_placement_volumetric.py
+++ b/harness/tests/scene_runtime/test_placement_volumetric.py
@@ -19,12 +19,10 @@ from __future__ import annotations
import pytest
-from codeverse3d.config import get_settings
from tests.scene_runtime.conftest import needs_node, run_node_json
pytestmark = [pytest.mark.node, needs_node]
-RUNTIME_JS = get_settings().runtime_js_dir()
#: `HAZE_DEPTH_WRITE` is the one thing that changes between the two arms below.
SCENE_JS = """
@@ -70,7 +68,7 @@ console.log(JSON.stringify({
def _run(depth_write: str) -> dict:
- body = SCENE_JS.replace("HAZE_DEPTH_WRITE", depth_write).replace("'./lib/", f"'{RUNTIME_JS}/lib/")
+ body = SCENE_JS.replace("HAZE_DEPTH_WRITE", depth_write)
return run_node_json(body)
@@ -147,6 +145,6 @@ console.log(JSON.stringify({ exempt: t.exempt,
def test_scatter_that_also_carries_fog_is_exempt_as_instanced():
"""Both reasons are true; `instanced` says the useful thing (its instances cannot be
sampled at this budget), so it wins."""
- out = run_node_json(SCATTER_JS.replace("'./lib/", f"'{RUNTIME_JS}/lib/"))
+ out = run_node_json(SCATTER_JS)
row = [a for a in out["rows"] if a["name"] == "TuftsAndHaze"]
assert row and row[0]["exempt"] == "instanced"