Skip to content

Commit f00016e

Browse files
committed
Cleanup fixture imports
`random_string` now comes from `test.fixtures` and was being transparently imported via `test.testutil` so this bypasses the pointless indirect import. Similarly, `kafka_version` was transparently imported by `test.testutil` from `test.fixtures`. Also removed `random_port()` in `test.testutil` because its unused as its been replaced by the one in `test.fixtures`. This is part of the pytest migration that was started back in a1869c4.
1 parent 1945ad1 commit f00016e

7 files changed

+10
-15
lines changed

test/conftest.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
import pytest
66

7-
from test.fixtures import KafkaFixture, ZookeeperFixture
8-
from test.testutil import kafka_version, random_string
7+
from test.fixtures import KafkaFixture, ZookeeperFixture, random_string, version as kafka_version
8+
99

1010
@pytest.fixture(scope="module")
1111
def version():

test/test_codec.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
lz4_encode_old_kafka, lz4_decode_old_kafka,
1515
)
1616

17-
from test.testutil import random_string
17+
from test.fixtures import random_string
1818

1919

2020
def test_gzip():

test/test_consumer_group.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from kafka.structs import TopicPartition
1414

1515
from test.conftest import version
16-
from test.testutil import random_string
16+
from test.fixtures import random_string
1717

1818

1919
def get_connect_str(kafka_broker):

test/test_consumer_integration.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
)
2525

2626
from test.conftest import version
27-
from test.fixtures import ZookeeperFixture, KafkaFixture
27+
from test.fixtures import ZookeeperFixture, KafkaFixture, random_string
2828
from test.testutil import (
29-
KafkaIntegrationTestCase, kafka_versions, random_string, Timer,
29+
KafkaIntegrationTestCase, kafka_versions, Timer,
3030
send_messages
3131
)
3232

test/test_failover_integration.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
from kafka.producer.base import Producer
1010
from kafka.structs import TopicPartition
1111

12-
from test.fixtures import ZookeeperFixture, KafkaFixture
13-
from test.testutil import KafkaIntegrationTestCase, random_string
12+
from test.fixtures import ZookeeperFixture, KafkaFixture, random_string
13+
from test.testutil import KafkaIntegrationTestCase
1414

1515

1616
log = logging.getLogger(__name__)

test/test_producer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from kafka import KafkaConsumer, KafkaProducer, TopicPartition
99
from kafka.producer.buffer import SimpleBufferPool
1010
from test.conftest import version
11-
from test.testutil import random_string
11+
from test.fixtures import random_string
1212

1313

1414
def test_buffer_pool():

test/testutil.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from kafka.structs import OffsetRequestPayload, ProduceRequestPayload
2020
from test.fixtures import random_string, version_str_to_list, version as kafka_version #pylint: disable=wrong-import-order
2121

22+
2223
def kafka_versions(*versions):
2324

2425
def construct_lambda(s):
@@ -65,12 +66,6 @@ def wrapper(func, *args, **kwargs):
6566

6667
return real_kafka_versions
6768

68-
def get_open_port():
69-
sock = socket.socket()
70-
sock.bind(("", 0))
71-
port = sock.getsockname()[1]
72-
sock.close()
73-
return port
7469

7570
_MESSAGES = {}
7671
def msg(message):

0 commit comments

Comments
 (0)