diff --git a/src/PythonClient/setup.py b/src/PythonClient/setup.py index 6b3e0db73..0650b8574 100644 --- a/src/PythonClient/setup.py +++ b/src/PythonClient/setup.py @@ -83,7 +83,7 @@ def update_version_in_package(vers: str, fromvers: str = "local"): python_requires='>=3.6, <4', install_requires=[ 'pandas>=1.0.0,<2', - 'Deprecated>=1.1,<2', + 'Deprecated>=1.1,<2' ] ) finally: diff --git a/src/PythonClient/src/quixstreams/exceptions/__init__.py b/src/PythonClient/src/quixstreams/exceptions/__init__.py deleted file mode 100644 index 2fa6d33bf..000000000 --- a/src/PythonClient/src/quixstreams/exceptions/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .quixapiexception import * diff --git a/src/PythonClient/src/requirements.txt b/src/PythonClient/src/requirements.txt index 142527739..23cd0108c 100644 --- a/src/PythonClient/src/requirements.txt +++ b/src/PythonClient/src/requirements.txt @@ -1 +1 @@ -pandas>=1.0.0,<2 +pandas>=1.0.0,<2 \ No newline at end of file diff --git a/src/PythonClient/tests/LICENSE.pytest b/src/PythonClient/tests/LICENSE.pytest deleted file mode 100644 index c3f1657fc..000000000 --- a/src/PythonClient/tests/LICENSE.pytest +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2004 Holger Krekel and others - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/src/PythonClient/tests/conftest.py b/src/PythonClient/tests/conftest.py index e69de29bb..4a79d92a0 100644 --- a/src/PythonClient/tests/conftest.py +++ b/src/PythonClient/tests/conftest.py @@ -0,0 +1,8 @@ +import src.quixstreams as qx + +# Uncomment the next lines to enable low-level interop logs +# It will also create a log file +# from src.quixstreams.native.Python.InteropHelpers.InteropUtils import InteropUtils +# InteropUtils.enable_debug() + +qx.Logging.update_factory(qx.LogLevel.Critical) diff --git a/src/PythonClient/tests/pytest.ini b/src/PythonClient/tests/pytest.ini deleted file mode 100644 index ac247b740..000000000 --- a/src/PythonClient/tests/pytest.ini +++ /dev/null @@ -1,8 +0,0 @@ -[pytest] -# Treat each async test as asyncio test -asyncio_mode = auto -# Ignore manual tests by and some loggers by default -addopts = --ignore=tests/quixstreams/manual --log-disable=urllib3.connectionpool --log-disable=parso --log-disable=asyncio -# Print debug logs to the console in tests -log_cli = True -log_cli_level = DEBUG diff --git a/src/PythonClient/tests/quixstreams/__init__.py b/src/PythonClient/tests/quixstreams/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/PythonClient/tests/quixstreams/conftest.py b/src/PythonClient/tests/quixstreams/conftest.py deleted file mode 100644 index b926a1f8c..000000000 --- a/src/PythonClient/tests/quixstreams/conftest.py +++ /dev/null @@ -1,35 +0,0 @@ -import pytest - -import src.quixstreams as qx -from tests.quixstreams.integrationtests.containerhelper import ContainerHelper -from .types import KafkaContainer -from .logging import LOGGING_CONFIG, patch_logger_class -import logging.config - -# Uncomment the next lines to enable low-level interop logs -# It will also create a log file -# from src.quixstreams.native.Python.InteropHelpers.InteropUtils import InteropUtils -# InteropUtils.enable_debug() - -qx.Logging.update_factory(qx.LogLevel.Critical) - - -@pytest.fixture(autouse=True) -def configure_logging(): - logging.config.dictConfig(LOGGING_CONFIG) - patch_logger_class() - - -@pytest.fixture(scope="session") -def kafka_container() -> KafkaContainer: - ( - kafka_container, - broker_address, - kafka_port, - zookeeper_port, - ) = ContainerHelper.create_kafka_container() - print(f"Starting Kafka container on {broker_address}") - ContainerHelper.start_kafka_container(kafka_container) - print(f"Started Kafka container on {broker_address}") - yield KafkaContainer(broker_address=broker_address) - kafka_container.stop() diff --git a/src/PythonClient/tests/quixstreams/integrationtests/conftest.py b/src/PythonClient/tests/quixstreams/integrationtests/conftest.py index 544f7878e..98d9eb351 100644 --- a/src/PythonClient/tests/quixstreams/integrationtests/conftest.py +++ b/src/PythonClient/tests/quixstreams/integrationtests/conftest.py @@ -2,7 +2,8 @@ from src import quixstreams as qx from src.quixstreams import AutoOffsetReset -from tests.quixstreams.types import KafkaContainer +from .containerhelper import ContainerHelper +from .types import KafkaContainer @pytest.fixture() @@ -15,7 +16,14 @@ def test_name(request: pytest.FixtureRequest) -> str: ) - +@pytest.fixture(scope='session') +def kafka_container() -> KafkaContainer: + kafka_container, broker_address, kafka_port, zookeeper_port = ContainerHelper.create_kafka_container() + print("Starting Kafka container") + ContainerHelper.start_kafka_container(kafka_container) + print("Started Kafka container") + yield KafkaContainer(broker_address=broker_address) + kafka_container.stop() @pytest.fixture() diff --git a/src/PythonClient/tests/quixstreams/types.py b/src/PythonClient/tests/quixstreams/integrationtests/types.py similarity index 100% rename from src/PythonClient/tests/quixstreams/types.py rename to src/PythonClient/tests/quixstreams/integrationtests/types.py diff --git a/src/PythonClient/tests/quixstreams/logging.py b/src/PythonClient/tests/quixstreams/logging.py deleted file mode 100644 index 2fe81b5fd..000000000 --- a/src/PythonClient/tests/quixstreams/logging.py +++ /dev/null @@ -1,75 +0,0 @@ -import functools -import logging -from typing import Mapping - -# Logging config to be used in tests -LOGGING_CONFIG = { - "version": 1, - "formatters": { - "standard": { - "format": "%(asctime)s [%(levelname)s] %(name)s: %(message)s", - }, - }, - "handlers": { - "default": { - "level": "INFO", - "class": "logging.StreamHandler", - "formatter": "standard", - }, - }, - "loggers": { - "confluent_kafka": { - "handlers": ["default"], - "level": "DEBUG", - "propagate": False, - }, - "src": { - "handlers": ["default"], - "level": "DEBUG", - "propagate": False, - }, - "quixstreams": { - "handlers": ["default"], - "level": "DEBUG", - "propagate": False, - }, - }, -} - - -def patch_logger_class(): - """ - Patch default logger class to output all data from "extra" in test logs - """ - logger_cls = logging.getLoggerClass() - # Patch makeRecord() of the default Logger class to print all "extra" fields in logs - logger_cls.makeRecord = _patch_makeRecord(logger_cls.makeRecord) - - -def _patch_makeRecord(func_): - @functools.wraps(func_) - def makeRecord_wrapper( - self, - name: str, - level: int, - fn: str, - lno: int, - msg: object, - args, - exc_info, - func: str | None = ..., - extra: Mapping[str, object] | None = ..., - sinfo: str | None = ..., - ) -> logging.LogRecord: - """ - Print all field from "extra" dict in the logs in tests - """ - record = func_( - self, name, level, fn, lno, msg, args, exc_info, func, extra, sinfo - ) - if extra is not None: - extra_str = " ".join(f"{k}={v}" for k, v in extra.items()) - record.msg += " " + extra_str - return record - - return makeRecord_wrapper diff --git a/src/PythonClient/tests/requirements.txt b/src/PythonClient/tests/requirements.txt index fc9455ede..8f2497517 100644 --- a/src/PythonClient/tests/requirements.txt +++ b/src/PythonClient/tests/requirements.txt @@ -1,4 +1,4 @@ testcontainers~=3.7.0 pytest psutil -numpy==1.24.3 +numpy==1.24.3 \ No newline at end of file