Skip to content

Commit f8d62fa

Browse files
authored
Merge pull request #342 from reportportal/develop
Release
2 parents e96c92f + b250825 commit f8d62fa

29 files changed

+324
-254
lines changed

.flake8

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[flake8]
2+
max-line-length = 119

.github/workflows/tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ on: [ push, pull_request ]
1717

1818
jobs:
1919
build:
20-
runs-on: ubuntu-20.04
20+
runs-on: ubuntu-latest
2121
strategy:
2222
matrix:
23-
python-version: [ '2.7', '3.6', '3.7', '3.8', '3.9', '3.10' ]
23+
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11' ]
2424
steps:
2525
- name: Checkout repository
2626
uses: actions/checkout@v3
@@ -39,7 +39,7 @@ jobs:
3939
run: tox
4040

4141
- name: Upload coverage to Codecov
42-
if: matrix.python-version == 3.6 && success()
42+
if: matrix.python-version == 3.7 && success()
4343
uses: codecov/codecov-action@v3
4444
with:
4545
files: coverage.xml

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
## [Unreleased]
44
### Added
5+
- `rp_launch_uuid_print` and `rp_launch_uuid_print_output` configuration parameters, by @HardNorth
6+
### Removed
7+
- Python 2.7, 3.6 support, by @HardNorth
8+
9+
## [5.1.9]
10+
### Added
511
- `rp_api_retries` configuration parameter, by @HardNorth
612
### Changed
713
- Client version updated on [5.3.5](https://github.com/reportportal/client-Python/releases/tag/5.3.5), by @HardNorth

README.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,18 @@ The following parameters are optional:
8484
- :code:`rp_launch = AnyLaunchName` - launch name (could be overridden by pytest --rp-launch option, default value is 'Pytest Launch').
8585
- :code:`rp_launch_id = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx` - id of the existing launch (the session will not handle the lifecycle of the given launch).
8686
- :code:`rp_launch_attributes = 'PyTest' 'Smoke' 'Env:Python3'` - list of attributes for launch.
87+
- :code:`rp_launch_description = 'Smoke test'` - launch description (could be overridden by pytest --rp-launch-description option, default value is '').
88+
- :code:`rp_launch_timeout = 86400` - Maximum time to wait for child processes finish, default value: 86400 seconds (1 day).
89+
- :code:`rp_launch_uuid_print = True` - Enables printing Launch UUID on test run start. Default `False`.
90+
- :code:`rp_launch_uuid_print_output = stderr` - Launch UUID print output. Default `stdout`. Possible values: [stderr, stdout].
8791
- :code:`rp_parent_item_id = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx` - id of the existing test item for session to use as parent item for the tests (the session will not handle the lifecycle of the given test item).
8892
- :code:`rp_tests_attributes = 'PyTest' 'Smoke'` - list of attributes that will be added for each item in the launch.
89-
- :code:`rp_launch_description = 'Smoke test'` - launch description (could be overridden by pytest --rp-launch-description option, default value is '').
9093
- :code:`rp_log_batch_size = 20` - size of batch log request.
9194
- :code:`rp_log_batch_payload_size = 65000000` - maximum payload size in bytes of async batch log requests.
9295
- :code:`rp_log_level = INFO` - The log level that will be reported.
9396
- :code:`rp_log_format = [%(levelname)7s] (%(name)s) %(message)s (%(filename)s:%(lineno)s)` - Format string to be used for logs sent to the service.
9497
- :code:`rp_ignore_attributes = 'xfail' 'usefixture'` - Ignore specified pytest markers.
95-
- :code:`rp_is_skipped_an_issue = False` - Treat skipped tests as required investigation. Default is True.
98+
- :code:`rp_is_skipped_an_issue = False` - Treat skipped tests as required investigation. Default `True`.
9699
- :code:`rp_hierarchy_dirs_level = 0` - Directory starting hierarchy level (from pytest.ini level) (default `0`).
97100
- :code:`rp_hierarchy_dirs = True` - Enables hierarchy for tests directories, default `False`. Doesn't support 'xdist' plugin.
98101
- :code:`rp_hierarchy_dir_path_separator` - Path separator to display directories in test hierarchy. In case of empty value current system path separator will be used (os.path.sep).
@@ -102,7 +105,6 @@ The following parameters are optional:
102105
- :code:`rp_verify_ssl = True` - Verify SSL when connecting to the server.
103106
- :code:`rp_mode = DEFAULT` - DEBUG or DEFAULT launch mode. DEBUG launches are displayed in a separate tab and not visible to anyone except owner.
104107
- :code:`rp_thread_logging` - EXPERIMENTAL - Enables support for reporting logs from threads by patching the builtin Thread class. Use with caution.
105-
- :code:`rp_launch_timeout = 86400` - Maximum time to wait for child processes finish, default value: 86400 seconds (1 day).
106108
- :code:`rp_api_retries = 0` - Amount of retries for performing REST calls to RP server.
107109

108110

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[build-system]
22
requires = [
33
# sync with setup.py until we discard non-pep-517/518
4-
"setuptools>=40.0",
4+
"setuptools>=68.0.0",
55
"setuptools-scm",
6-
"wheel==0.37.1",
6+
"wheel==0.40.0",
77
]
88
build-backend = "setuptools.build_meta"

pytest_reportportal/config.py

Lines changed: 53 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
"""This module contains class that stores RP agent configuration data."""
2+
import sys
23
import warnings
34

45
from distutils.util import strtobool
56
from os import getenv
7+
from typing import Optional, Union, Any, TextIO, Dict
68

9+
from _pytest.config import Config
710
from reportportal_client.logs.log_manager import MAX_LOG_BATCH_PAYLOAD_SIZE
811

912
try:
@@ -14,10 +17,49 @@
1417
get_actual_log_level
1518

1619

20+
OUTPUT_TYPES: Dict[str, TextIO] = {
21+
'stdout': sys.stdout,
22+
'stderr': sys.stderr
23+
}
24+
25+
1726
class AgentConfig(object):
1827
"""Storage for the RP agent initialization attributes."""
1928

20-
def __init__(self, pytest_config):
29+
rp_rerun: Optional[bool]
30+
pconfig: Config
31+
rp_endpoint: str
32+
rp_hierarchy_code: bool
33+
rp_dir_level: int
34+
rp_hierarchy_dirs: bool
35+
rp_dir_path_separator: str
36+
rp_ignore_attributes: set
37+
rp_is_skipped_an_issue: bool
38+
rp_issue_id_marks: bool
39+
rp_issue_system_url: str
40+
rp_bts_project: str
41+
rp_bts_url: str
42+
rp_launch: str
43+
rp_launch_id: Optional[str]
44+
rp_launch_attributes: Optional[list]
45+
rp_launch_description: str
46+
rp_log_batch_size: int
47+
rp_log_batch_payload_size: int
48+
rp_log_level: Optional[int]
49+
rp_log_format: Optional[str]
50+
rp_mode: str
51+
rp_parent_item_id: Optional[str]
52+
rp_project: str
53+
rp_rerun_of: Optional[str]
54+
rp_api_retries: int
55+
rp_skip_connection_test: bool
56+
rp_api_key: str
57+
rp_verify_ssl: Union[bool, str]
58+
rp_launch_timeout: int
59+
rp_launch_uuid_print: bool
60+
rp_launch_uuid_print_output: TextIO
61+
62+
def __init__(self, pytest_config: Config) -> None:
2163
"""Initialize required attributes."""
2264
self.rp_rerun = (pytest_config.option.rp_rerun or
2365
pytest_config.getini('rp_rerun'))
@@ -30,10 +72,7 @@ def __init__(self, pytest_config):
3072
'rp_hierarchy_dirs')
3173
self.rp_dir_path_separator = \
3274
self.find_option(pytest_config, 'rp_hierarchy_dir_path_separator')
33-
ignore_attributes = self.find_option(pytest_config,
34-
'rp_ignore_attributes')
35-
self.rp_ignore_attributes = set(ignore_attributes) \
36-
if ignore_attributes else set()
75+
self.rp_ignore_attributes = set(self.find_option(pytest_config, 'rp_ignore_attributes') or [])
3776
self.rp_is_skipped_an_issue = self.find_option(
3877
pytest_config,
3978
'rp_is_skipped_an_issue'
@@ -127,8 +166,15 @@ def __init__(self, pytest_config):
127166
self.rp_launch_timeout = int(
128167
self.find_option(pytest_config, 'rp_launch_timeout'))
129168

169+
self.rp_launch_uuid_print = bool(strtobool(self.find_option(
170+
pytest_config, 'rp_launch_uuid_print'
171+
) or 'False'))
172+
self.rp_launch_uuid_print_output = OUTPUT_TYPES.get((self.find_option(
173+
pytest_config, 'rp_launch_uuid_print_output'
174+
) or 'stdout').lower(), OUTPUT_TYPES['stdout'])
175+
130176
# noinspection PyMethodMayBeStatic
131-
def find_option(self, pytest_config, option_name, default=None):
177+
def find_option(self, pytest_config: Config, option_name: str, default: Any = None):
132178
"""
133179
Find a single configuration setting from multiple places.
134180
@@ -148,4 +194,4 @@ def find_option(self, pytest_config, option_name, default=None):
148194
)
149195
if isinstance(value, bool):
150196
return value
151-
return value if value else default
197+
return value or default

pytest_reportportal/config.pyi

Lines changed: 0 additions & 39 deletions
This file was deleted.

pytest_reportportal/plugin.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ def pytest_sessionstart(session):
104104

105105
if is_control(config) and not config._reporter_config.rp_launch_id:
106106
config.py_test_service.start_launch()
107+
if config._reporter_config.rp_launch_uuid_print:
108+
launch_id = config.py_test_service.rp.launch_id
109+
print(f'Report Portal Launch UUID: {launch_id}', file=config._reporter_config.rp_launch_uuid_print_output)
107110
if config.pluginmanager.hasplugin('xdist') \
108111
or config.pluginmanager.hasplugin('pytest-parallel'):
109112
if not wait_launch(session.config.py_test_service.rp):
@@ -400,6 +403,16 @@ def add_shared_option(name, help_str, default=None, action='store'):
400403
default=False,
401404
action='store_true'
402405
)
406+
add_shared_option(
407+
name='rp_launch_uuid_print',
408+
help_str='Enables printing Launch UUID on test run start. Possible values: [True, False]',
409+
default='False'
410+
)
411+
add_shared_option(
412+
name='rp_launch_uuid_print_output',
413+
help_str='Launch UUID print output. Default `stdout`. Possible values: [stderr, stdout]',
414+
default='stdout'
415+
)
403416

404417
parser.addini(
405418
'rp_launch_attributes',

0 commit comments

Comments
 (0)