diff options
author | Jeff Widman <jeff@jeffwidman.com> | 2019-08-22 01:58:28 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-22 01:58:28 -0700 |
commit | 98c005852e36fde0ef44a7b9c60a54f4686651af (patch) | |
tree | 82f0f218064cd8163addc43042a71207e86cadc9 /test/test_producer.py | |
parent | e49caeb3ebdd36eb4d18a517bc402f8e89dfdbee (diff) | |
download | kafka-python-98c005852e36fde0ef44a7b9c60a54f4686651af.tar.gz |
Cleanup handling of KAFKA_VERSION env var in tests (#1887)
Now that we are using `pytest`, there is no need for a custom decorator
because we can use `pytest.mark.skipif()`.
This makes the code significantly simpler. In particular, dropping the
custom `@kafka_versions()` decorator is necessary because it uses
`func.wraps()` which doesn't play nice with `pytest` fixtures:
- https://github.com/pytest-dev/pytest/issues/677
- https://stackoverflow.com/a/19614807/770425
So this is a pre-requisite to migrating some of those tests to using
pytest fixtures.
Diffstat (limited to 'test/test_producer.py')
-rw-r--r-- | test/test_producer.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/test/test_producer.py b/test/test_producer.py index 60b19bf..9605adf 100644 --- a/test/test_producer.py +++ b/test/test_producer.py @@ -7,7 +7,7 @@ import pytest from kafka import KafkaConsumer, KafkaProducer, TopicPartition from kafka.producer.buffer import SimpleBufferPool -from test.fixtures import random_string, version +from test.testutil import env_kafka_version, random_string def test_buffer_pool(): @@ -22,13 +22,13 @@ def test_buffer_pool(): assert buf2.read() == b'' -@pytest.mark.skipif(not version(), reason="No KAFKA_VERSION set") +@pytest.mark.skipif(not env_kafka_version(), reason="No KAFKA_VERSION set") @pytest.mark.parametrize("compression", [None, 'gzip', 'snappy', 'lz4']) def test_end_to_end(kafka_broker, compression): if compression == 'lz4': # LZ4 requires 0.8.2 - if version() < (0, 8, 2): + if env_kafka_version() < (0, 8, 2): return # python-lz4 crashes on older versions of pypy elif platform.python_implementation() == 'PyPy': @@ -80,7 +80,7 @@ def test_kafka_producer_gc_cleanup(): assert threading.active_count() == threads -@pytest.mark.skipif(not version(), reason="No KAFKA_VERSION set") +@pytest.mark.skipif(not env_kafka_version(), reason="No KAFKA_VERSION set") @pytest.mark.parametrize("compression", [None, 'gzip', 'snappy', 'lz4']) def test_kafka_producer_proper_record_metadata(kafka_broker, compression): connect_str = ':'.join([kafka_broker.host, str(kafka_broker.port)]) @@ -91,7 +91,7 @@ def test_kafka_producer_proper_record_metadata(kafka_broker, compression): magic = producer._max_usable_produce_magic() # record headers are supported in 0.11.0 - if version() < (0, 11, 0): + if env_kafka_version() < (0, 11, 0): headers = None else: headers = [("Header Key", b"Header Value")] |