diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f8ff469..9f2d4a2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -34,7 +34,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [ '3.9', '3.10', '3.11', '3.12', '3.13', '3.14', '3.15' ] + python-version: [ '3.10', '3.11', '3.12', '3.13', '3.14', '3.15' ] steps: - name: Checkout repository uses: actions/checkout@v4 diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a1de2d..db23b71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ # Changelog ## [Unreleased] +### Fixed +- Issue [#283](https://github.com/reportportal/client-Python/issues/283): Async RPClient doesn't close client session, by @BlueX888 +### Removed +- `Python 3.9` support, by @HardNorth + +## [5.7.12] ### Changed - `certify` version range updated to mitigate a compromised certificate issue, by @HardNorth diff --git a/reportportal_client/__init__.py b/reportportal_client/__init__.py index 5fe2e93..4180cbd 100644 --- a/reportportal_client/__init__.py +++ b/reportportal_client/__init__.py @@ -18,7 +18,6 @@ from enum import Enum from typing import Optional, TypedDict, Union -# noinspection PyUnreachableCode if sys.version_info >= (3, 11): from typing import Unpack else: diff --git a/reportportal_client/_internal/aio/tasks.py b/reportportal_client/_internal/aio/tasks.py index 263a4fd..f653bd1 100644 --- a/reportportal_client/_internal/aio/tasks.py +++ b/reportportal_client/_internal/aio/tasks.py @@ -17,15 +17,10 @@ import sys import time from asyncio import Future -from typing import Any, Coroutine, Generator, Generic, Optional, TypeVar, Union +from typing import Any, Coroutine, Generator, Generic, Optional, TypeAlias, TypeVar, Union from reportportal_client.aio.tasks import BlockingOperationError, Task -if sys.version_info >= (3, 10): - from typing import TypeAlias -else: - from typing_extensions import TypeAlias - _T = TypeVar("_T") DEFAULT_TASK_TRIGGER_NUM: int = 10 diff --git a/reportportal_client/aio/client.py b/reportportal_client/aio/client.py index d3ebe7a..ad33528 100644 --- a/reportportal_client/aio/client.py +++ b/reportportal_client/aio/client.py @@ -771,6 +771,7 @@ def __setstate__(self, state: dict[str, Any]) -> None: :param dict state: object state dictionary """ self.__dict__.update(state) + self._session = None class AsyncRPClient(RP): @@ -1365,7 +1366,7 @@ def __init__( self.own_client = False else: self.__client = Client(endpoint, project, **kwargs) - self.own_client = False + self.own_client = True self.__launch_uuid = launch_uuid if launch_uuid: diff --git a/reportportal_client/aio/tasks.py b/reportportal_client/aio/tasks.py index b9913ea..40eea92 100644 --- a/reportportal_client/aio/tasks.py +++ b/reportportal_client/aio/tasks.py @@ -17,12 +17,7 @@ import sys from abc import abstractmethod from asyncio import Future -from typing import Any, Coroutine, Generator, Generic, Optional, TypeVar, Union - -if sys.version_info >= (3, 10): - from typing import TypeAlias -else: - from typing_extensions import TypeAlias +from typing import Any, Coroutine, Generator, Generic, Optional, TypeAlias, TypeVar, Union # noinspection PyProtectedMember from reportportal_client._internal.static.abstract import AbstractBaseClass diff --git a/setup.py b/setup.py index 1c6ecc9..38423ab 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ from setuptools import find_packages, setup -__version__ = "5.7.12" +__version__ = "5.8.0" TYPE_STUBS = ["*.pyi"] @@ -39,7 +39,6 @@ def read_file(fname): license="Apache-2.0", keywords=["testing", "reporting", "reportportal", "client"], classifiers=[ - "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", diff --git a/tests/aio/test_batched_client.py b/tests/aio/test_batched_client.py index 48343ff..56e72c5 100644 --- a/tests/aio/test_batched_client.py +++ b/tests/aio/test_batched_client.py @@ -18,16 +18,27 @@ # noinspection PyPackageRequirements import pytest -from reportportal_client.aio import BatchedRPClient +from reportportal_client.aio import BatchedRPClient, ThreadedRPClient from reportportal_client.core.rp_requests import AsyncRPRequestLog from reportportal_client.helpers import timestamp +@pytest.mark.parametrize("client_class", [BatchedRPClient, ThreadedRPClient]) +def test_own_client_reflects_client_ownership(client_class): + owned = client_class("http://endpoint", "project", api_key="api_key") + assert owned.own_client is True + + borrowed = client_class("http://endpoint", "project", api_key="api_key", client=mock.AsyncMock()) + assert borrowed.own_client is False + + def test_batched_rp_client_pickling(): client = BatchedRPClient("http://localhost:8080", "default_personal", api_key="test_key") pickled_client = pickle.dumps(client) unpickled_client = pickle.loads(pickled_client) assert unpickled_client is not None + assert unpickled_client.own_client is True + unpickled_client.close() async def __empty_string(): diff --git a/tox.ini b/tox.ini index 8518999..c310c00 100644 --- a/tox.ini +++ b/tox.ini @@ -2,7 +2,6 @@ isolated_build = True envlist = pep - py39 py310 py311 py312 @@ -31,7 +30,6 @@ commands = pre-commit run --all-files --show-diff-on-failure [gh-actions] python = - 3.9: py39 3.10: pep, py310 3.11: py311 3.12: py312