# Buggy code
def process(self):
    event = self.receive_message()

    try:
        self.output.lpush(self.queue, event)
    except Exception:
        self.logger.exception("Failed to send message. Reconnecting.")
        self.connect()
    else:
        self.acknowledge_message()


# Traceback (nose.proxy.AssertionError)
======================================================================
FAIL: Setup Redis connection
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/travis/build/wagner-certat/intelmq/intelmq/tests/bots/outputs/redis/test_output.py", line 65, in test_event
self.run_bot()
File "/home/travis/build/wagner-certat/intelmq/intelmq/lib/test.py", line 290, in run_bot
self.assertNotRegexpMatchesLog("(ERROR.*?){%d}" % (self.allowed_error_count + 1))
File "/home/travis/build/wagner-certat/intelmq/intelmq/lib/test.py", line 450, in assertNotRegexpMatchesLog
self.assertNotRegex(self.loglines_buffer, pattern)
nose.proxy.AssertionError: Regex matched: 'ERROR' matches '(ERROR.*?){1}' in '2018-11-15 16:34:18,125 - test-bot - INFO - RedisOutputBot initialized with id test-bot and intelmq 1.2.0.alpha1 and python 3.4.6 (default, May 22 2017, 19:25:03) as process 5867.\n2018-11-15 16:34:18,126 - test-bot - INFO - Bot is starting.\n2018-11-15 16:34:18,128 - test-bot - INFO - Connected successfully to Redis 4.0.6 at 127.0.0.1:6379!\n2018-11-15 16:34:18,130 - test-bot - ERROR - Failed to send message. Reconnecting.\nTraceback (most recent call last):\n  File "/home/travis/build/wagner-certat/intelmq/intelmq/bots/outputs/redis/output.py", line 25, in process\n    self.output.lpush(self.queue, event)\n  File "/home/travis/virtualenv/python3.4.6/lib/python3.4/site-packages/redis/client.py", line 1554, in lpush\n    return self.execute_command(\'LPUSH\', name, *values)\n  File "/home/travis/virtualenv/python3.4.6/lib/python3.4/site-packages/redis/client.py", line 754, in execute_command\n    connection.send_command(*args)\n  File "/home/travis/virtualenv/python3.4.6/lib/python3.4/site-packages/redis/connection.py", line 619, in send_command\n    self.send_packed_command(self.pack_command(*args))\n  File "/home/travis/virtualenv/python3.4.6/lib/python3.4/site-packages/redis/connection.py", line 659, in pack_command\n    for arg in imap(self.encoder.encode, args):\n  File "/home/travis/virtualenv/python3.4.6/lib/python3.4/site-packages/redis/connection.py", line 124, in encode\n    "byte, string or number first." % typename)\nredis.exceptions.DataError: Invalid input of type: \'Event\'. Convert to a byte, string or number first.\n2018-11-15 16:34:18,133 - test-bot - INFO - Connected successfully to Redis 4.0.6 at 127.0.0.1:6379!\n2018-11-15 16:34:18,134 - test-bot - INFO - Bot stopped.\n'
-------------------- >> begin captured logging << --------------------
test-bot: INFO: RedisOutputBot initialized with id test-bot and intelmq 1.2.0.alpha1 and python 3.4.6 (default, May 22 2017, 19:25:03) as process 5867.
test-bot: INFO: Bot is starting.
test-bot: INFO: Connected successfully to Redis 4.0.6 at 127.0.0.1:6379!
test-bot: ERROR: Failed to send message. Reconnecting.
Traceback (most recent call last):
File "/home/travis/build/wagner-certat/intelmq/intelmq/bots/outputs/redis/output.py", line 25, in process
self.output.lpush(self.queue, event)
File "/home/travis/virtualenv/python3.4.6/lib/python3.4/site-packages/redis/client.py", line 1554, in lpush
return self.execute_command('LPUSH', name, *values)
File "/home/travis/virtualenv/python3.4.6/lib/python3.4/site-packages/redis/client.py", line 754, in execute_command
connection.send_command(*args)
File "/home/travis/virtualenv/python3.4.6/lib/python3.4/site-packages/redis/connection.py", line 619, in send_command
self.send_packed_command(self.pack_command(*args))
File "/home/travis/virtualenv/python3.4.6/lib/python3.4/site-packages/redis/connection.py", line 659, in pack_command
for arg in imap(self.encoder.encode, args):
File "/home/travis/virtualenv/python3.4.6/lib/python3.4/site-packages/redis/connection.py", line 124, in encode
"byte, string or number first." % typename)
redis.exceptions.DataError: Invalid input of type: 'Event'. Convert to a byte, string or number first.
test-bot: INFO: Connected successfully to Redis 4.0.6 at 127.0.0.1:6379!
test-bot: INFO: Bot stopped.
--------------------- >> end captured logging << ---------------------

# Fixed code
def process(self):
    event = self.receive_message()

    try:
        self.output.lpush(self.queue, str(event))
    except Exception:
        self.logger.exception("Failed to send message. Reconnecting.")
        self.connect()
    else:
        self.acknowledge_message()