def test_heartbeat_append_exception(self): heartbeat = Heartbeat(60, None) heartbeat._exceptions = [] def check(exception): heartbeat._raise_or_append_exception() if exception: raise exception.pop() self.assertRaisesRegexp( AMQPConnectionError, 'Connection dead, no heartbeat or data received in >= 120s', check, heartbeat._exceptions ) heartbeat._interval = 120 self.assertRaisesRegexp( AMQPConnectionError, 'Connection dead, no heartbeat or data received in >= 240', check, heartbeat._exceptions )