diff --git a/core/input.py b/core/input.py index cc450c7..fce461e 100644 --- a/core/input.py +++ b/core/input.py @@ -38,7 +38,7 @@ def __invoke(event, callback): if not callback: return if not 'button' in event: return - for cb in callback.get(event['button']): + for cb in callback.get(event['button'], []): if callable(cb): cb(event) else: diff --git a/tests/core/test_input.py b/tests/core/test_input.py index e469543..8e68f4c 100644 --- a/tests/core/test_input.py +++ b/tests/core/test_input.py @@ -17,6 +17,11 @@ class config(unittest.TestCase): core.input.trigger(self.someEvent) self.callback.assert_called_once_with(self.someEvent) + def test_nonexistent_callback(self): + core.input.register(self.inputObject, self.someEvent['button'], self.callback) + core.input.trigger(self.anotherEvent) + self.callback.assert_not_called() + def test_different_events(self): core.input.register(self.inputObject, self.someEvent['button'], self.callback) core.input.register(self.inputObject, self.anotherEvent['button'], self.callback)