@mock.patch('statsd.Connection')
    @mock.patch('statsd.Gauge')
    def test_event_listener(self, mock_gauge, mock_connection):
        config = {
            'statsd': {
                'host': 'host',
            }
        }
        hass = mock.MagicMock()
        statsd.setup(hass, config)
        self.assertTrue(hass.bus.listen.called)
        handler_method = hass.bus.listen.call_args_list[0][0][1]

        valid = {'1': 1,
                 '1.0': 1.0,
                 STATE_ON: 1,
                 STATE_OFF: 0}
        for in_, out in valid.items():
            state = mock.MagicMock(state=in_)
            handler_method(mock.MagicMock(data={'new_state': state}))
            mock_gauge.return_value.send.assert_called_once_with(
                state.entity_id, out)
            mock_gauge.return_value.send.reset_mock()

        for invalid in ('foo', '', object):
            handler_method(mock.MagicMock(data={
                'new_state': ha.State('domain.test', invalid, {})}))
            self.assertFalse(mock_gauge.return_value.send.called)
Constructor arguments should be passed as keyword arguments only.
dataset/ETHPy150Open home-assistant/home-assistant/tests/components/test_statsd.py/TestStatsd.test_event_listener--crossover with--dataset/ETHPy150Open babble/babble/include/jython/Lib/cookielib.py/DefaultCookiePolicy.__init__