diff --git a/CHANGELOG.md b/CHANGELOG.md index 8beefd3..3358fd9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,13 @@ # Changelog ## [Unreleased] +### Changed +- Client version updated to [5.7.2](https://github.com/reportportal/client-Python/releases/tag/5.7.2), by @HardNorth +### Removed +- `aenum` dependency, by @HardNorth +- `dill` dependency, by @HardNorth + +## [5.6.2] ### Added - `rp_launch_uuid` configuration parameter, by @HardNorth - `rp_launch_attributes` cmd argument, by @fahadnaeemkhan diff --git a/pytest_reportportal/config.py b/pytest_reportportal/config.py index 0d6a702..29e56be 100644 --- a/pytest_reportportal/config.py +++ b/pytest_reportportal/config.py @@ -28,7 +28,7 @@ class AgentConfig: """Storage for the RP agent initialization attributes.""" rp_enabled: bool - rp_client_type: Optional[ClientType] + rp_client_type: ClientType rp_rerun: Optional[bool] pconfig: Config rp_endpoint: str @@ -72,7 +72,7 @@ class AgentConfig: rp_verify_ssl: Union[bool, str] rp_launch_timeout: int rp_launch_uuid_print: bool - rp_launch_uuid_print_output: Optional[OutputType] + rp_launch_uuid_print_output: OutputType rp_http_timeout: Optional[Union[tuple[float, float], float]] rp_report_fixtures: bool @@ -174,7 +174,7 @@ def __init__(self, pytest_config: Config) -> None: self.rp_launch_uuid_print = to_bool(self.find_option(pytest_config, "rp_launch_uuid_print") or "False") print_output = self.find_option(pytest_config, "rp_launch_uuid_print_output") - self.rp_launch_uuid_print_output = OutputType[print_output.upper()] if print_output else None + self.rp_launch_uuid_print_output = OutputType[print_output.upper()] if print_output else OutputType.STDOUT client_type = self.find_option(pytest_config, "rp_client_type") self.rp_client_type = ClientType[client_type.upper()] if client_type else ClientType.SYNC diff --git a/pytest_reportportal/plugin.py b/pytest_reportportal/plugin.py index 1798b14..6fab6aa 100644 --- a/pytest_reportportal/plugin.py +++ b/pytest_reportportal/plugin.py @@ -15,12 +15,12 @@ import logging import os.path +import pickle import time from logging import Logger from typing import Any, Callable, Generator import _pytest.logging -import dill as pickle import pytest # noinspection PyPackageRequirements diff --git a/pytest_reportportal/service.py b/pytest_reportportal/service.py index c0dff67..bbd6f36 100644 --- a/pytest_reportportal/service.py +++ b/pytest_reportportal/service.py @@ -20,13 +20,13 @@ import threading import traceback from collections import OrderedDict +from enum import Enum from functools import wraps from os import curdir from time import sleep, time from typing import Any, Callable, Generator, Optional, Union from _pytest.doctest import DoctestItem -from aenum import Enum, auto, unique from py.path import local from pytest import Class, Function, Item, Module, Package, PytestWarning, Session from reportportal_client.aio import Task @@ -74,7 +74,7 @@ except ImportError: Rule = type("dummy", (), {}) # Old pytest-bdd versions do not have Rule -from reportportal_client import RP, ClientType, create_client +from reportportal_client import RP, OutputType, create_client from reportportal_client.helpers import dict_to_payload, gen_attributes, get_launch_sys_attrs, get_package_version LOGGER = logging.getLogger(__name__) @@ -125,25 +125,23 @@ def trim_docstring(docstring: str) -> str: return "\n".join(trimmed) -@unique class LeafType(Enum): """This class stores test item path types.""" - DIR = auto() - FILE = auto() - CODE = auto() - ROOT = auto() - SUITE = auto() - NESTED = auto() + DIR = 1 + FILE = 2 + CODE = 3 + ROOT = 4 + SUITE = 5 + NESTED = 6 -@unique class ExecStatus(Enum): """This class stores test item path types.""" - CREATED = auto() - IN_PROGRESS = auto() - FINISHED = auto() + CREATED = 1 + IN_PROGRESS = 2 + FINISHED = 3 def check_rp_enabled(func): @@ -190,7 +188,7 @@ def __init__(self, agent_config: AgentConfig) -> None: self._start_tracker = set() self._launch_id = None self.agent_name = "pytest-reportportal" - self.agent_version = get_package_version(self.agent_name) + self.agent_version = get_package_version(self.agent_name) or "None" self.ignored_attributes = [] self.parent_item_id = None self.rp = None @@ -221,7 +219,7 @@ def _get_launch_attributes(self, ini_attrs: Optional[list[dict[str, str]]]) -> l attributes = ini_attrs or [] system_attributes = get_launch_sys_attrs() system_attributes["agent"] = "{}|{}".format(self.agent_name, self.agent_version) - return attributes + dict_to_payload(system_attributes) + return attributes + (dict_to_payload(system_attributes) or []) def _build_start_launch_rq(self) -> dict[str, Any]: rp_launch_attributes = self._config.rp_launch_attributes @@ -366,6 +364,7 @@ def _get_scenario_template(self, scenario: Scenario) -> Optional[ScenarioTemplat break if scenario_template and isinstance(scenario_template, ScenarioTemplate): return scenario_template + return None def _get_method_name(self, item: Item) -> str: """Get the original test method name. @@ -650,20 +649,20 @@ def _get_test_case_id( else: return base_name + param_str - def _get_issue_ids(self, mark): - issue_ids = mark.kwargs.get("issue_id", []) + def _get_issue_ids(self, mark) -> list[Any]: + issue_ids = mark.kwargs.get("issue_id", []) or [] if not isinstance(issue_ids, list): issue_ids = [issue_ids] return issue_ids - def _get_issue_urls(self, mark, default_url): + def _get_issue_urls(self, mark, default_url: str) -> list[Optional[str]]: issue_ids = self._get_issue_ids(mark) if not issue_ids: - return None + return [] mark_url = mark.kwargs.get("url", None) or default_url - return [mark_url.format(issue_id=issue_id) if mark_url else None for issue_id in issue_ids] + return [str(mark_url).format(issue_id=str(issue_id)) if mark_url else None for issue_id in issue_ids] - def _get_issue_description_line(self, mark, default_url): + def _get_issue_description_line(self, mark, default_url: str) -> str: issue_ids = self._get_issue_ids(mark) if not issue_ids: return mark.kwargs["reason"] @@ -693,7 +692,7 @@ def _get_issue(self, mark: Mark) -> Optional[Issue]: issue_short_name = mark.kwargs["issue_type"] # default value - issue_short_name = "TI" if issue_short_name is None else issue_short_name + issue_short_name = "TI" if issue_short_name is None else str(issue_short_name) registered_issues = self.issue_types issue = None @@ -824,7 +823,8 @@ def _process_attributes(self, item: Item) -> list[dict[str, Any]]: test_attributes = self._config.rp_tests_attributes if test_attributes: attributes = { - (attr.get("key", None), attr["value"]) for attr in gen_attributes(self._config.rp_tests_attributes) + (attr.get("key", None), attr["value"]) + for attr in gen_attributes(self._config.rp_tests_attributes or []) } else: attributes = set() @@ -1420,7 +1420,7 @@ def start(self) -> None: if self._config.rp_launch_uuid: launch_id = self._config.rp_launch_uuid self.rp = create_client( - client_type=self._config.rp_client_type or ClientType.SYNC, + client_type=self._config.rp_client_type, endpoint=self._config.rp_endpoint, project=self._config.rp_project, api_key=self._config.rp_api_key, @@ -1431,7 +1431,7 @@ def start(self) -> None: launch_uuid=launch_id, log_batch_payload_limit=self._config.rp_log_batch_payload_limit, launch_uuid_print=self._config.rp_launch_uuid_print, - print_output=self._config.rp_launch_uuid_print_output, + print_output=self._config.rp_launch_uuid_print_output or OutputType.STDOUT, http_timeout=self._config.rp_http_timeout, mode=self._config.rp_mode, # OAuth 2.0 parameters diff --git a/requirements-dev.txt b/requirements-dev.txt index 4f1e860..76a8e25 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,4 +1,3 @@ -dill>=0.3.6 pytest>=4.6.10 delayed-assert pytest-cov diff --git a/requirements.txt b/requirements.txt index ca2b79b..0944a3d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1 @@ -reportportal-client==5.7.1 -aenum==3.1.17 +reportportal-client==5.7.2 diff --git a/setup.py b/setup.py index 6f72db0..2e6a4e1 100644 --- a/setup.py +++ b/setup.py @@ -17,7 +17,7 @@ from setuptools import setup -__version__ = "5.6.2" +__version__ = "5.6.3" def read_file(fname): diff --git a/tests/integration/test_config_handling.py b/tests/integration/test_config_handling.py index 16d421f..df6bdf5 100644 --- a/tests/integration/test_config_handling.py +++ b/tests/integration/test_config_handling.py @@ -214,7 +214,7 @@ def test_launch_uuid_print(mock_client_init): assert int(result) == 0, "Exit code should be 0 (no errors)" expect(mock_client_init.call_count == 1) expect(mock_client_init.call_args_list[0][1]["launch_uuid_print"] == print_uuid) - expect(mock_client_init.call_args_list[0][1]["print_output"] is None) + expect(mock_client_init.call_args_list[0][1]["print_output"] is OutputType.STDOUT) assert_expectations() @@ -248,7 +248,7 @@ def test_no_launch_uuid_print(mock_client_init): assert int(result) == 0, "Exit code should be 0 (no errors)" expect(mock_client_init.call_count == 1) expect(mock_client_init.call_args_list[0][1]["launch_uuid_print"] is False) - expect(mock_client_init.call_args_list[0][1]["print_output"] is None) + expect(mock_client_init.call_args_list[0][1]["print_output"] is OutputType.STDOUT) assert_expectations()