Skip to content

Commit 78b893a

Browse files
authored
Merge pull request #333 from reportportal/develop
Release
2 parents a3e192c + f1e5040 commit 78b893a

File tree

8 files changed

+41
-32
lines changed

8 files changed

+41
-32
lines changed

pytest_reportportal/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from distutils.util import strtobool
44
from os import getenv
55

6-
from reportportal_client.core.log_manager import MAX_LOG_BATCH_PAYLOAD_SIZE
6+
from reportportal_client.logs.log_manager import MAX_LOG_BATCH_PAYLOAD_SIZE
77

88
try:
99
# This try/except can go away once we support pytest >= 5.4.0

pytest_reportportal/plugin.py

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
import pytest
1212
import requests
1313
from reportportal_client import RPLogHandler
14-
from reportportal_client.core.log_manager import MAX_LOG_BATCH_PAYLOAD_SIZE
1514
from reportportal_client.errors import ResponseError
15+
from reportportal_client.logs.log_manager import MAX_LOG_BATCH_PAYLOAD_SIZE
1616

1717
from pytest_reportportal import LAUNCH_WAIT_TIMEOUT
1818
from .config import AgentConfig
@@ -34,6 +34,7 @@ def pytest_configure_node(node):
3434
3535
:param node: Object of the xdist WorkerController class
3636
"""
37+
# noinspection PyProtectedMember
3738
if not node.config._rp_enabled:
3839
# Stop now if the plugin is not properly configured
3940
return
@@ -62,6 +63,7 @@ def wait_launch(rp_client):
6263
time.sleep(1)
6364

6465

66+
# noinspection PyProtectedMember
6567
def pytest_sessionstart(session):
6668
"""Start Report Portal launch.
6769
@@ -96,13 +98,15 @@ def pytest_collection_finish(session):
9698
9799
:param session: Object of the pytest Session class
98100
"""
101+
# noinspection PyProtectedMember
99102
if not session.config._rp_enabled:
100103
# Stop now if the plugin is not properly configured
101104
return
102105

103106
session.config.py_test_service.collect_tests(session)
104107

105108

109+
# noinspection PyProtectedMember
106110
def pytest_sessionfinish(session):
107111
"""Finish current test session.
108112
@@ -162,6 +166,7 @@ def check_connection(agent_config):
162166
return False
163167

164168

169+
# noinspection PyProtectedMember
165170
def pytest_configure(config):
166171
"""Update Config object with attributes required for reporting to RP.
167172
@@ -204,6 +209,7 @@ def pytest_configure(config):
204209
config.workerinput['py_test_service'])
205210

206211

212+
# noinspection PyProtectedMember
207213
@pytest.hookimpl(hookwrapper=True)
208214
def pytest_runtestloop(session):
209215
"""
@@ -222,6 +228,7 @@ def pytest_runtestloop(session):
222228
yield
223229

224230

231+
# noinspection PyProtectedMember
225232
@pytest.hookimpl(hookwrapper=True)
226233
def pytest_runtest_protocol(item):
227234
"""
@@ -253,6 +260,7 @@ def pytest_runtest_protocol(item):
253260
service.finish_pytest_item(item)
254261

255262

263+
# noinspection PyProtectedMember
256264
@pytest.hookimpl(hookwrapper=True)
257265
def pytest_runtest_makereport(item):
258266
"""
@@ -278,28 +286,28 @@ def pytest_addoption(parser):
278286
"""
279287
group = parser.getgroup('reporting')
280288

281-
def add_shared_option(name, help, default=None, action='store'):
289+
def add_shared_option(name, help_str, default=None, action='store'):
282290
"""
283291
Add an option to both the command line and the .ini file.
284292
285293
This function modifies `parser` and `group` from the outer scope.
286294
287295
:param name: name of the option
288-
:param help: help message
296+
:param help_str: help message
289297
:param default: default value
290298
:param action: `group.addoption` action
291299
"""
292300
parser.addini(
293301
name=name,
294302
default=default,
295-
help=help,
303+
help=help_str,
296304
)
297305
group.addoption(
298306
'--{0}'.format(name.replace('_', '-')),
299307
action=action,
300308
dest=name,
301309
help='{help} (overrides {name} config option)'.format(
302-
help=help,
310+
help=help_str,
303311
name=name,
304312
),
305313
)
@@ -313,57 +321,57 @@ def add_shared_option(name, help, default=None, action='store'):
313321
)
314322
add_shared_option(
315323
name='rp_launch',
316-
help='Launch name',
324+
help_str='Launch name',
317325
default='Pytest Launch',
318326
)
319327
add_shared_option(
320328
name='rp_launch_id',
321-
help='Use already existing launch-id. The plugin won\'t control the '
322-
'Launch status',
329+
help_str='Use already existing launch-id. The plugin won\'t control '
330+
'the Launch status',
323331
)
324332
add_shared_option(
325333
name='rp_launch_description',
326-
help='Launch description',
334+
help_str='Launch description',
327335
default='',
328336
)
329-
add_shared_option(name='rp_project', help='Project name')
337+
add_shared_option(name='rp_project', help_str='Project name')
330338
add_shared_option(
331339
name='rp_log_level',
332-
help='Logging level for automated log records reporting',
340+
help_str='Logging level for automated log records reporting',
333341
)
334342
add_shared_option(
335343
name='rp_log_format',
336-
help='Logging format for automated log records reporting',
344+
help_str='Logging format for automated log records reporting',
337345
)
338346
add_shared_option(
339347
name='rp_rerun',
340-
help='Marks the launch as a rerun',
348+
help_str='Marks the launch as a rerun',
341349
default=False,
342350
action='store_true',
343351
)
344352
add_shared_option(
345353
name='rp_rerun_of',
346-
help='ID of the launch to be marked as a rerun (use only with '
347-
'rp_rerun=True)',
354+
help_str='ID of the launch to be marked as a rerun (use only with '
355+
'rp_rerun=True)',
348356
default='',
349357
)
350358
add_shared_option(
351359
name='rp_parent_item_id',
352-
help='Create all test item as child items of the given (already '
353-
'existing) item.',
360+
help_str='Create all test item as child items of the given (already '
361+
'existing) item.',
354362
)
355-
add_shared_option(name='rp_uuid', help='UUID')
356-
add_shared_option(name='rp_endpoint', help='Server endpoint')
363+
add_shared_option(name='rp_uuid', help_str='UUID')
364+
add_shared_option(name='rp_endpoint', help_str='Server endpoint')
357365
add_shared_option(
358366
name='rp_mode',
359-
help='Visibility of current launch [DEFAULT, DEBUG]',
367+
help_str='Visibility of current launch [DEFAULT, DEBUG]',
360368
default='DEFAULT'
361369
)
362370
add_shared_option(
363371
name='rp_thread_logging',
364-
help='EXPERIMENTAL: Report logs from threads. '
365-
'This option applies a patch to the builtin Thread class, '
366-
'and so it is turned off by default. Use with caution.',
372+
help_str='EXPERIMENTAL: Report logs from threads. '
373+
'This option applies a patch to the builtin Thread class, '
374+
'and so it is turned off by default. Use with caution.',
367375
default=False,
368376
action='store_true'
369377
)

pytest_reportportal/service.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
# in pytest >= 7.0 this type was removed
2020
Instance = type('dummy', (), {})
2121
from reportportal_client.client import RPClient
22-
from reportportal_client.external.google_analytics import send_event
2322
from reportportal_client.helpers import (
2423
dict_to_payload,
2524
gen_attributes,
@@ -134,7 +133,7 @@ def _get_launch_attributes(self, ini_attrs):
134133
attributes = ini_attrs or []
135134
system_attributes = get_launch_sys_attrs()
136135
system_attributes['agent'] = (
137-
'{}-{}'.format(self.agent_name, self.agent_version))
136+
'{}|{}'.format(self.agent_name, self.agent_version))
138137
return attributes + dict_to_payload(system_attributes)
139138

140139
def _build_start_launch_rq(self):
@@ -165,8 +164,6 @@ def start_launch(self):
165164
log.debug('ReportPortal - Start launch: request_body=%s', sl_pt)
166165
self._launch_id = self.rp.start_launch(**sl_pt)
167166
log.debug('ReportPortal - Launch started: id=%s', self._launch_id)
168-
if not self._skip_analytics:
169-
send_event(self.agent_name, self.agent_version)
170167
return self._launch_id
171168

172169
def _get_item_dirs(self, item):
@@ -878,9 +875,10 @@ def start(self):
878875
launch_id=launch_id,
879876
log_batch_payload_size=self._config.rp_log_batch_payload_size
880877
)
881-
if self.rp and hasattr(self.rp, "get_project_settings"):
878+
if hasattr(self.rp, "get_project_settings"):
882879
self.project_settings = self.rp.get_project_settings()
883880
self.rp.start()
881+
# noinspection PyUnresolvedReferences
884882
self._start_tracker.add(self.__unique_id())
885883

886884
def stop(self):

pytest_reportportal/service.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@ class PyTestServiceClass:
3636
project_settings: Dict[Text, Any] = ...
3737

3838
def __init__(self, agent_config: AgentConfig) -> None: ...
39+
def start(self) -> None: ...

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
dill>=0.2.7.1
22
pytest>=3.8.0
3-
reportportal-client==5.2.5
3+
reportportal-client==5.3.0
44
six>=1.15.0
55
aenum>=3.1.0
66
requests

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from setuptools import setup
66

77

8-
__version__ = '5.1.5'
8+
__version__ = '5.1.6'
99

1010

1111
def read_file(fname):

tests/unit/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from _pytest.main import Session
1919
from pluggy._tracing import TagTracer
2020
from pytest import fixture, Module
21+
# noinspection PyUnresolvedReferences
2122
from six.moves import mock
2223

2324
from reportportal_client import RPLogger

tests/unit/test_plugin.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""This modules includes unit tests for the plugin."""
1+
"""This module includes unit tests for the plugin."""
22

33
# Copyright (c) 2021 http://reportportal.io .
44
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,6 +17,7 @@
1717
import pytest
1818
from delayed_assert import expect, assert_expectations
1919
from requests.exceptions import RequestException
20+
# noinspection PyUnresolvedReferences
2021
from six.moves import mock
2122

2223
from reportportal_client.errors import ResponseError

0 commit comments

Comments
 (0)