"""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()