Files
dora-joy/tests/conftest.py
cristhian 3624c63ead
validate / validate (pull_request) Successful in 58m42s
validate / test (pull_request) Successful in 58m47s
validate / markdownlint (pull_request) Successful in 58m40s
add dora-joy node publishing gamepad axes and buttons
2026-09-16 05:10:33 -05:00

31 lines
917 B
Python

"""Shared fakes. Nothing here needs a gamepad."""
import pytest
from dora_joy.config import Config
from dora_joy.gamepad import Sample
def stick(axes=None, buttons=None, present=True):
"""Build one gamepad reading, padded to a full six axes."""
values = list(axes or [])
values += [0.0] * (6 - len(values))
# A trigger at rest reads -1, and a test that forgot to say so would look
# like both triggers held down.
for index in (2, 5):
if axes is None or index >= len(axes):
values[index] = -1.0
return Sample(axes=values, buttons=list(buttons or []), present=present)
@pytest.fixture(autouse=True)
def clean_env(monkeypatch):
"""Run every test against a bare environment, whatever the shell set."""
monkeypatch.delenv("JOYSTICK_INDEX", raising=False)
@pytest.fixture
def config():
"""Return the default configuration."""
return Config.from_env()