Skip to content

Commit 34fea65

Browse files
authored
Minor test cleanups (#1343)
1 parent 298709d commit 34fea65

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

test/test_consumer_group.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ def consumer_thread(i):
6868
for tp, records in six.itervalues(consumers[i].poll(100)):
6969
messages[i][tp].extend(records)
7070
consumers[i].close()
71-
del consumers[i]
72-
del stop[i]
71+
consumers[i] = None
72+
stop[i] = None
7373

7474
num_consumers = 4
7575
for i in range(num_consumers):
@@ -134,6 +134,7 @@ def consumer_thread(i):
134134
logging.info('Stopping consumer %s', c)
135135
stop[c].set()
136136
threads[c].join()
137+
threads[c] = None
137138

138139

139140
@pytest.mark.skipif(not version(), reason="No KAFKA_VERSION set")

test/test_coordinator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ def patched_coord(mocker, coordinator):
400400
return_value=1)
401401
mocker.patch.object(coordinator._client, 'ready', return_value=True)
402402
mocker.patch.object(coordinator._client, 'send')
403+
mocker.patch.object(coordinator, '_heartbeat_thread')
403404
mocker.spy(coordinator, '_failed_request')
404405
mocker.spy(coordinator, '_handle_offset_commit_response')
405406
mocker.spy(coordinator, '_handle_offset_fetch_response')

test/test_producer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ def test_end_to_end(kafka_broker, compression):
7272
@pytest.mark.skipif(platform.python_implementation() != 'CPython',
7373
reason='Test relies on CPython-specific gc policies')
7474
def test_kafka_producer_gc_cleanup():
75+
gc.collect()
7576
threads = threading.active_count()
7677
producer = KafkaProducer(api_version='0.9') # set api_version explicitly to avoid auto-detection
7778
assert threading.active_count() == threads + 1

0 commit comments

Comments
 (0)