core.testing package

Submodules

core.testing.mock_input module

MockInputProvider for unit-testing scripts without pygame.

Usage:

from core.input import Input
from core.testing import MockInputProvider

mock = MockInputProvider()
Input.set_provider(mock)

mock.press_key(pygame.K_SPACE)
assert Input.get_key(pygame.K_SPACE) is True

mock.release_key(pygame.K_SPACE)
assert Input.get_key(pygame.K_SPACE) is False

mock.set_mouse_pos(100, 200)
assert Input.get_mouse_position() == (100, 200)

# Restore default input when done
Input.clear_provider()
class core.testing.mock_input.MockInputProvider[source]

Bases: object

Drop-in provider for Input.set_provider() that fakes keyboard, mouse, and axis state without requiring a pygame display.

get_axis(axis_name: str) float[source]
get_events() list[source]
get_game_mouse_position() tuple[float, float][source]
get_key(key_code: int) bool[source]
get_mouse_button(button_index: int) bool[source]
get_mouse_position() tuple[float, float][source]
inject_event(event)[source]

Add a synthetic event to the events list for this frame.

press_key(key_code: int)[source]

Simulate pressing a key.

press_mouse_button(button: int)[source]

Simulate pressing a mouse button (0=left, 1=middle, 2=right).

release_key(key_code: int)[source]

Simulate releasing a key.

release_mouse_button(button: int)[source]

Simulate releasing a mouse button.

reset()[source]

Clear all simulated state.

set_axis(name: str, value: float)[source]

Set a named axis value (-1.0 to 1.0).

set_game_mouse_pos(x: float, y: float)[source]

Set the game-space mouse position independently.

set_mouse_pos(x: float, y: float)[source]

Set the current mouse position.

update()[source]

No-op — state is set explicitly by the test.

Module contents

class core.testing.MockInputProvider[source]

Bases: object

Drop-in provider for Input.set_provider() that fakes keyboard, mouse, and axis state without requiring a pygame display.

get_axis(axis_name: str) float[source]
get_events() list[source]
get_game_mouse_position() tuple[float, float][source]
get_key(key_code: int) bool[source]
get_mouse_button(button_index: int) bool[source]
get_mouse_position() tuple[float, float][source]
inject_event(event)[source]

Add a synthetic event to the events list for this frame.

press_key(key_code: int)[source]

Simulate pressing a key.

press_mouse_button(button: int)[source]

Simulate pressing a mouse button (0=left, 1=middle, 2=right).

release_key(key_code: int)[source]

Simulate releasing a key.

release_mouse_button(button: int)[source]

Simulate releasing a mouse button.

reset()[source]

Clear all simulated state.

set_axis(name: str, value: float)[source]

Set a named axis value (-1.0 to 1.0).

set_game_mouse_pos(x: float, y: float)[source]

Set the game-space mouse position independently.

set_mouse_pos(x: float, y: float)[source]

Set the current mouse position.

update()[source]

No-op — state is set explicitly by the test.