simvx.core.testing.diagnostics

Diagnostics – scene comparison, description, and performance measurement.

Module Contents

Classes

NodeCounter

Count nodes by type in a scene tree. Useful for debugging and assertions.

FrameTimer

Measure frame timing for performance testing.

Functions

scene_diff

Compare two scene snapshots and return a list of human-readable differences.

scene_describe

Return a tree-formatted text description of the scene hierarchy.

ui_describe

Return a tree-formatted text description of a UI widget hierarchy.

Data

API

simvx.core.testing.diagnostics.__all__

[‘scene_diff’, ‘NodeCounter’, ‘FrameTimer’, ‘scene_describe’, ‘ui_describe’]

simvx.core.testing.diagnostics.scene_diff(before: dict, after: dict, _path: str = '') list[str][source]

Compare two scene snapshots and return a list of human-readable differences.

Each entry describes a single change, e.g.: “Root/Player.position: (0, 0) -> (10, 5)” “Root/Enemy: REMOVED” “Root/PowerUp: ADDED (Node2D)”

class simvx.core.testing.diagnostics.NodeCounter[source]

Count nodes by type in a scene tree. Useful for debugging and assertions.

static count(root: simvx.core.node.Node) dict[str, int][source]

Return a dict mapping type name to count.

static total(root: simvx.core.node.Node) int[source]

Return total number of nodes in the tree.

class simvx.core.testing.diagnostics.FrameTimer[source]

Measure frame timing for performance testing.

Usage: timer = FrameTimer() for _ in range(100): timer.begin_frame() runner.advance_frames(1) timer.end_frame() print(f”Average: {timer.average_ms:.2f}ms, FPS: {timer.fps:.0f}”)

Initialization

begin_frame() None[source]
end_frame() None[source]
property average_ms: float
property max_ms: float
property min_ms: float
property fps: float
property frame_count: int
reset() None[source]
simvx.core.testing.diagnostics.scene_describe(root: simvx.core.node.Node, include_properties: bool = True, include_layout: bool = True) str[source]

Return a tree-formatted text description of the scene hierarchy.

Uses box-drawing chars for hierarchy. Each line shows the node name, type, and relevant state (position, rotation, scale, visibility, Property values). Designed for LLM consumption – an LLM can read this to understand what’s on screen.

simvx.core.testing.diagnostics.ui_describe(root, include_layout: bool = True) str[source]

Return a tree-formatted text description of a UI widget hierarchy.

Focused on UI-specific info: widget type, text content, rect, focus, visibility. Designed for LLM consumption – an LLM can read this to understand the UI state.