simvx.core.testing.scene_runner

SceneRunner – headless scene runner for testing game logic.

Module Contents

Classes

SceneRunner

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:InputSimulator pending-release queue at the start of every iteration so sim.tap_key() can fire the release on a later frame than the press (preserving the is_action_just_pressed / is_action_just_released edges).

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 None if 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: True if the predicate was satisfied within max_ticks, False on timeout. The predicate is evaluated BEFORE the first tick so an already-satisfied state returns True with zero frames advanced.

Replaces the per-test for _ in range(N): runner.advance_frames(1); if cond(): break boilerplate (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]
property frame_count: int[source]
property elapsed_time: float[source]
snapshot() dict[source]

Capture current scene state as a serializable dict.