

def test_error():
    proto = MessageProtocol()
    proto.sendMessage = MagicMock()
    expected_message = {
        'type': 'error',
        'description': 'BANG!',
    }
    proto.error('BANG!')
    assert (1 == proto.sendMessage.call_count)
    assert (expected_message == proto.sendMessage.call_args[0][0])

dataset/ETHPy150Open hpk42/p4p/tests/test_protocol.py test_error/original