simvx.core.testing.scene_runner¶
SceneRunner – headless scene runner for testing game logic.
Module Contents¶
Classes¶
Headless scene runner for testing game logic without rendering. |
Data¶
API¶
- simvx.core.testing.scene_runner.log¶
‘getLogger(…)’
- simvx.core.testing.scene_runner.__all__¶
[‘SceneRunner’]
- class simvx.core.testing.scene_runner.SceneRunner(screen_size: tuple[float, float] = (800, 600))[source]¶
Headless scene runner for testing game logic without rendering.
Manages a SceneTree, advances frames, and provides query helpers.
Initialization
- load(root_node: simvx.core.node.Node) simvx.core.testing.scene_runner.SceneRunner[source]¶
Load a scene by setting the root node.
- advance_frames(count: int = 1, dt: float | None = None, draw: bool = False) simvx.core.testing.scene_runner.SceneRunner[source]¶
Advance the scene by N frames (tick + physics_tick each).
If draw is True, also calls
tree.render()with a mock renderer each frame. This exercises draw() methods and catches errors that would otherwise only surface with a real Vulkan renderer.Drains :class:
InputSimulatorpending-release queue at the start of every iteration sosim.tap_key()can fire the release on a later frame than the press (preserving theis_action_just_pressed/is_action_just_releasededges).
- simulate_until(predicate, max_ticks: int = 600, dt: float | None = None) bool[source]¶
Tick the scene until
predicate(scene)returns truthy.Args: predicate: Callable receiving the scene root (or
Noneif no root) and returning a truthy value when the desired state has been reached. max_ticks: Maximum frames to advance before giving up. Default 600 (10 seconds at 60 FPS). dt: Frame timestep. Defaults to the runner’s_dt(1/60 s).Returns:
Trueif the predicate was satisfied withinmax_ticks,Falseon timeout. The predicate is evaluated BEFORE the first tick so an already-satisfied state returnsTruewith zero frames advanced.Replaces the per-test
for _ in range(N): runner.advance_frames(1); if cond(): breakboilerplate (You’re the OS, PyDew Valley).
- advance_time(seconds: float, dt: float | None = None) simvx.core.testing.scene_runner.SceneRunner[source]¶
Advance the scene by approximately N seconds worth of frames.
- find(name_or_type, recursive: bool = True) simvx.core.node.Node | None[source]¶
Find a node by name (str) or by type in the scene tree.
- find_all(node_type: type) list[simvx.core.node.Node][source]¶
Find all nodes of a given type in the scene.
- property root: simvx.core.node.Node | None[source]¶