From b99a9eee64aa9dec34f43085a551d076513b9f51 Mon Sep 17 00:00:00 2001 From: Dana Powers Date: Sun, 31 Aug 2014 11:13:02 -0700 Subject: Import cleanups in tests --- test/test_protocol.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'test/test_protocol.py') diff --git a/test/test_protocol.py b/test/test_protocol.py index 2089f48..b1c5201 100644 --- a/test/test_protocol.py +++ b/test/test_protocol.py @@ -1,10 +1,8 @@ -import contextlib -from contextlib import contextmanager +from contextlib import contextmanager, nested import struct -import unittest2 -import mock -from mock import sentinel +import unittest2 +from mock import patch, sentinel from kafka import KafkaClient from kafka.common import ( @@ -701,12 +699,12 @@ class TestProtocol(unittest2.TestCase): @contextmanager def mock_create_message_fns(self): - patches = contextlib.nested( - mock.patch.object(kafka.protocol, "create_message", + patches = nested( + patch.object(kafka.protocol, "create_message", return_value=sentinel.message), - mock.patch.object(kafka.protocol, "create_gzip_message", + patch.object(kafka.protocol, "create_gzip_message", return_value=sentinel.gzip_message), - mock.patch.object(kafka.protocol, "create_snappy_message", + patch.object(kafka.protocol, "create_snappy_message", return_value=sentinel.snappy_message), ) -- cgit v1.2.1 From 1b282d21522d101f4129d5fc3e70e2b904d3b171 Mon Sep 17 00:00:00 2001 From: Dana Powers Date: Mon, 1 Sep 2014 17:24:50 -0700 Subject: Cleanup tests: no more import *; remove unused --- test/test_protocol.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'test/test_protocol.py') diff --git a/test/test_protocol.py b/test/test_protocol.py index b1c5201..f6e3c96 100644 --- a/test/test_protocol.py +++ b/test/test_protocol.py @@ -4,20 +4,15 @@ import struct import unittest2 from mock import patch, sentinel -from kafka import KafkaClient from kafka.common import ( OffsetRequest, OffsetCommitRequest, OffsetFetchRequest, OffsetResponse, OffsetCommitResponse, OffsetFetchResponse, ProduceRequest, FetchRequest, Message, ChecksumError, ConsumerFetchSizeTooSmall, ProduceResponse, FetchResponse, OffsetAndMessage, - BrokerMetadata, PartitionMetadata, TopicAndPartition, KafkaUnavailableError, - ProtocolError, LeaderUnavailableError, PartitionUnavailableError, + BrokerMetadata, PartitionMetadata, ProtocolError, UnsupportedCodecError ) -from kafka.codec import ( - has_snappy, gzip_encode, gzip_decode, - snappy_encode, snappy_decode -) +from kafka.codec import has_snappy, gzip_decode, snappy_decode import kafka.protocol from kafka.protocol import ( ATTRIBUTE_CODEC_MASK, CODEC_NONE, CODEC_GZIP, CODEC_SNAPPY, KafkaProtocol, -- cgit v1.2.1