From bc87474632637dee3e09a878f91ee6ff38e3a8bd Mon Sep 17 00:00:00 2001 From: Jeff Widman Date: Thu, 22 Aug 2019 01:15:35 -0700 Subject: Cleanup handling of KAFKA_VERSION env var in tests 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. --- test/conftest.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'test/conftest.py') diff --git a/test/conftest.py b/test/conftest.py index b6d3e3e..5015cc7 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -2,14 +2,8 @@ from __future__ import absolute_import import pytest -from test.fixtures import KafkaFixture, ZookeeperFixture, random_string, version as kafka_version - - -@pytest.fixture(scope="module") -def version(): - """Return the Kafka version set in the OS environment""" - return kafka_version() - +from test.testutil import env_kafka_version, random_string +from test.fixtures import KafkaFixture, ZookeeperFixture @pytest.fixture(scope="module") def zookeeper(): @@ -26,9 +20,9 @@ def kafka_broker(kafka_broker_factory): @pytest.fixture(scope="module") -def kafka_broker_factory(version, zookeeper): +def kafka_broker_factory(zookeeper): """Return a Kafka broker fixture factory""" - assert version, 'KAFKA_VERSION must be specified to run integration tests' + assert env_kafka_version(), 'KAFKA_VERSION must be specified to run integration tests' _brokers = [] def factory(**broker_params): -- cgit v1.2.1