summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJeff Widman <jeff@jeffwidman.com>2018-05-10 16:12:19 -0700
committerJeff Widman <jeff@jeffwidman.com>2018-05-23 15:19:01 -0700
commit11cf3973bfc64ab0b4e471fc56dae911df1ec8d9 (patch)
tree474937a8c01bb32a3b12a944d9a9ad6b32d81800 /test
parent9221fcf83528b5c3657e43636cb84c1d18025acd (diff)
downloadkafka-python-11cf3973bfc64ab0b4e471fc56dae911df1ec8d9.tar.gz
Stop shadowing `ConnectionError`
In Python3, `ConnectionError` is a native exception. So rename our custom one to `KafkaConnectionError` to prevent accidentally shadowing the native one. Note that there are still valid uses of `ConnectionError` in this code. They already expect a native Python3 `ConnectionError`, and also already handle the Python2 compatibility issues.
Diffstat (limited to 'test')
-rw-r--r--test/test_client.py2
-rw-r--r--test/test_conn.py4
-rw-r--r--test/test_failover_integration.py6
3 files changed, 6 insertions, 6 deletions
diff --git a/test/test_client.py b/test/test_client.py
index d02c621..c53983c 100644
--- a/test/test_client.py
+++ b/test/test_client.py
@@ -8,7 +8,7 @@ from . import unittest
from kafka import SimpleClient
from kafka.errors import (
KafkaUnavailableError, LeaderNotAvailableError, KafkaTimeoutError,
- UnknownTopicOrPartitionError, ConnectionError, FailedPayloadsError)
+ UnknownTopicOrPartitionError, FailedPayloadsError)
from kafka.future import Future
from kafka.protocol import KafkaProtocol, create_message
from kafka.protocol.metadata import MetadataResponse
diff --git a/test/test_conn.py b/test/test_conn.py
index 12a32ef..fbdeeb9 100644
--- a/test/test_conn.py
+++ b/test/test_conn.py
@@ -99,7 +99,7 @@ def test_send_disconnected(conn):
conn.state = ConnectionStates.DISCONNECTED
f = conn.send('foobar')
assert f.failed() is True
- assert isinstance(f.exception, Errors.ConnectionError)
+ assert isinstance(f.exception, Errors.KafkaConnectionError)
def test_send_connecting(conn):
@@ -162,7 +162,7 @@ def test_send_error(_socket, conn):
_socket.send.side_effect = socket.error
f = conn.send(req)
assert f.failed() is True
- assert isinstance(f.exception, Errors.ConnectionError)
+ assert isinstance(f.exception, Errors.KafkaConnectionError)
assert _socket.close.call_count == 1
assert conn.state is ConnectionStates.DISCONNECTED
diff --git a/test/test_failover_integration.py b/test/test_failover_integration.py
index 797e1c8..ad7dcb9 100644
--- a/test/test_failover_integration.py
+++ b/test/test_failover_integration.py
@@ -4,7 +4,7 @@ import time
from kafka import SimpleClient, SimpleConsumer, KeyedProducer
from kafka.errors import (
- FailedPayloadsError, ConnectionError, RequestTimedOutError,
+ FailedPayloadsError, KafkaConnectionError, RequestTimedOutError,
NotLeaderForPartitionError)
from kafka.producer.base import Producer
from kafka.structs import TopicPartition
@@ -79,7 +79,7 @@ class TestFailover(KafkaIntegrationTestCase):
producer.send_messages(topic, partition, b'success')
log.debug("success!")
recovered = True
- except (FailedPayloadsError, ConnectionError, RequestTimedOutError,
+ except (FailedPayloadsError, KafkaConnectionError, RequestTimedOutError,
NotLeaderForPartitionError):
log.debug("caught exception sending message -- will retry")
continue
@@ -167,7 +167,7 @@ class TestFailover(KafkaIntegrationTestCase):
producer.send_messages(topic, key, msg)
if producer.partitioners[topic].partition(key) == 0:
recovered = True
- except (FailedPayloadsError, ConnectionError, RequestTimedOutError,
+ except (FailedPayloadsError, KafkaConnectionError, RequestTimedOutError,
NotLeaderForPartitionError):
log.debug("caught exception sending message -- will retry")
continue