Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions pytest_reportportal/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion pytest_reportportal/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
50 changes: 25 additions & 25 deletions pytest_reportportal/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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__)
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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"]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
dill>=0.3.6
pytest>=4.6.10
delayed-assert
pytest-cov
Expand Down
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
reportportal-client==5.7.1
aenum==3.1.17
reportportal-client==5.7.2
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from setuptools import setup

__version__ = "5.6.2"
__version__ = "5.6.3"


def read_file(fname):
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_config_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand Down Expand Up @@ -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()


Expand Down
Loading