diff --git a/bumblebee/input.py b/bumblebee/input.py index ba41362..7dea7d2 100644 --- a/bumblebee/input.py +++ b/bumblebee/input.py @@ -27,6 +27,8 @@ def read_input(inp): inp.has_event = True try: event = json.loads(line) + if not "instance" in event: + continue inp.callback(event) inp.redraw() except ValueError: diff --git a/tests/test_i3barinput.py b/tests/test_i3barinput.py index e2758d6..abe972f 100644 --- a/tests/test_i3barinput.py +++ b/tests/test_i3barinput.py @@ -47,7 +47,20 @@ class TestI3BarInput(unittest.TestCase): mock_input.readline.return_value = json.dumps({ "name": None, "instance": None, - "button": None, + "button": 1, + }) + self.input.start() + self.assertEquals(self.input.alive(), True) + self.assertEquals(self.input.stop(), True) + mock_input.readline.assert_any_call() + + @mock.patch("select.select") + @mock.patch("sys.stdin") + def test_ignore_partial_event(self, mock_input, mock_select): + mock_select.return_value = (1,2,3) + self.input.register_callback(None, button=1, cmd=self.callback) + mock_input.readline.return_value = json.dumps({ + "button": 1, }) self.input.start() self.assertEquals(self.input.alive(), True)