From 1f3f03579c2222a64a41d4749063a8a21195cb86 Mon Sep 17 00:00:00 2001 From: PoAn Yang Date: Fri, 29 Nov 2024 02:26:58 +0800 Subject: [PATCH] KAFKA-17979 Change [pytest] to [tool:pytest] in setup.cfg file (#17740) Reviewers: Chia-Ping Tsai --- tests/README.md | 2 +- tests/setup.cfg | 2 +- tests/setup.py | 12 ++++-------- tests/unit/setup.cfg | 2 +- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/tests/README.md b/tests/README.md index fe71cf45031..93c082b94bb 100644 --- a/tests/README.md +++ b/tests/README.md @@ -161,7 +161,7 @@ https://cwiki.apache.org/confluence/display/KAFKA/tutorial+-+set+up+and+run+Kafk $ cd kafka/tests $ virtualenv -p python3 venv $ . ./venv/bin/activate - $ python3 setup.py develop + $ python3 -m pip install --editable . $ cd .. # back to base kafka directory * Run the bootstrap script to set up Vagrant for testing diff --git a/tests/setup.cfg b/tests/setup.cfg index 974d5bb9a97..61e54430368 100644 --- a/tests/setup.cfg +++ b/tests/setup.cfg @@ -20,7 +20,7 @@ # # To ease possible confusion, 'check' instead of 'test' as a prefix for unit tests, since # many system test files, classes, and methods have 'test' somewhere in the name -[pytest] +[tool:pytest] testpaths=unit python_files=check_*.py python_classes=Check diff --git a/tests/setup.py b/tests/setup.py index c97ca819227..dcb023a32b9 100644 --- a/tests/setup.py +++ b/tests/setup.py @@ -15,27 +15,24 @@ import re import sys -from setuptools import find_packages, setup -from setuptools.command.test import test as TestCommand +from setuptools import find_packages, setup, Command version = '' with open('kafkatest/__init__.py', 'r') as fd: version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) -class PyTest(TestCommand): +class PyTest(Command): user_options = [('pytest-args=', 'a', "Arguments to pass to py.test")] def initialize_options(self): - TestCommand.initialize_options(self) self.pytest_args = [] def finalize_options(self): - TestCommand.finalize_options(self) self.test_args = [] self.test_suite = True - def run_tests(self): + def run(self): # import here, cause outside the eggs aren't loaded import pytest print(self.pytest_args) @@ -51,8 +48,7 @@ setup(name="kafkatest", license="apache2.0", packages=find_packages(), include_package_data=True, - install_requires=["ducktape==0.12.0", "requests==2.31.0", "psutil==5.7.2"], - tests_require=["pytest", "mock"], + install_requires=["ducktape==0.12.0", "requests==2.31.0", "psutil==5.7.2", "pytest==8.3.3", "mock==5.1.0"], cmdclass={'test': PyTest}, zip_safe=False ) diff --git a/tests/unit/setup.cfg b/tests/unit/setup.cfg index 3470da12185..8de3c3de792 100644 --- a/tests/unit/setup.cfg +++ b/tests/unit/setup.cfg @@ -17,7 +17,7 @@ # # To ease possible confusion, prefix muckrake *unit* tests with 'check' instead of 'test', since # many muckrake files, classes, and methods have 'test' somewhere in the name -[pytest] +[tool:pytest] python_files=check_*.py python_classes=Check python_functions=check_*