Skip to content

Commit 632871c

Browse files
author
Dzmitry Humianiuk
authored
Merge branch 'master' into fix-pytest-warning
2 parents 51ea38a + 22ec127 commit 632871c

File tree

6 files changed

+29
-14
lines changed

6 files changed

+29
-14
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ The following parameters are optional:
7777
- :code:`rp_hierarchy_parametrize = True` - Enables hierarchy parametrized tests, default `False`. Doesn't support 'xdist' plugin.
7878
- :code:`rp_hierarchy_dirs_level = 0` - Directory starting hierarchy level (from pytest.ini level) (default `0`)
7979
- :code:`rp_issue_marks = 'xfail' 'issue'` - Pytest marks that could be used to get issue information (id, type, reason)
80-
- :code:`rp_issue_system_url = https://bugzilla.olympus.f5net.com/show_bug.cgi?id=` - URL to get issue description (issue id from pytest mark will be added to this URL)
80+
- :code:`rp_issue_system_url = http://bugzilla.some.com/show_bug.cgi?id={%issue_id}` - issue URL (issue_id will be filled by parameter from pytest mark)
8181
- :code:`rp_verify_ssl = True` - Verify SSL when connecting to the server
8282
- :code:`rp_display_suite_test_file = True` In case of True, include the suite's relative file path in the launch name as a convention of "<RELATIVE_FILE_PATH>::<SUITE_NAME>". In case of False, set the launch name to be the suite name only - this flag is relevant only when "rp_hierarchy_module" flag is set to False
8383

pytest_reportportal/listener.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
import cgi
21
import pytest
32
import logging
3+
try:
4+
from html import escape # python3
5+
except ImportError:
6+
from cgi import escape # python2
47

58

69
try:
@@ -46,8 +49,7 @@ def pytest_runtest_makereport(self, item):
4649

4750
if report.longrepr:
4851
self.PyTestService.post_log(
49-
# Used for support python 2.7
50-
cgi.escape(report.longreprtext),
52+
escape(report.longreprtext),
5153
loglevel='ERROR',
5254
)
5355

@@ -101,17 +103,17 @@ def _add_issue_info(self, item, report):
101103
issue_ids = [issue_ids]
102104
comment += "\n" if comment else ""
103105
comment += "Issues:"
104-
105106
for issue_id in issue_ids:
106-
comment += " [{}]({}{})".format(issue_id, url, issue_id) if url else " {}".format(issue_id)
107+
template = (" [{issue_id}]" + "({})".format(url)) if url else " {issue_id}"
108+
comment += template.format(issue_id=issue_id)
107109

108110
if "issue_type" in mark.kwargs:
109111
issue_type = mark.kwargs["issue_type"]
110112

111-
if comment:
112-
self.issue['comment'] = comment
113-
114-
if issue_type and self.PyTestService.issue_types and (issue_type in self.PyTestService.issue_types):
113+
if issue_type and self.PyTestService.issue_types \
114+
and (issue_type in self.PyTestService.issue_types):
115+
if comment:
116+
self.issue['comment'] = comment
115117
self.issue['issue_type'] = self.PyTestService.issue_types[issue_type]
116118
# self.issue['ignoreAnalyzer'] = True ???
117119
elif (report.when == 'setup') and report.skipped:

pytest_reportportal/plugin.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ def pytest_sessionstart(session):
5454
log_batch_size=int(session.config.getini('rp_log_batch_size')),
5555
ignore_errors=bool(session.config.getini('rp_ignore_errors')),
5656
ignored_tags=session.config.getini('rp_ignore_tags'),
57-
verify_ssl=session.config.getini('rp_verify_ssl')
57+
verify_ssl=session.config.getini('rp_verify_ssl'),
58+
retries=int(session.config.getini('retries')),
5859
)
5960

6061
session.config.py_test_service.start_launch(
@@ -305,3 +306,8 @@ def pytest_addoption(parser):
305306
help="In case of True, include the suite's relative file path in the launch name as a convention of "
306307
"'<RELATIVE_FILE_PATH>::<SUITE_NAME>'. In case of False, set the launch name to be the suite name "
307308
"only - this flag is relevant only when 'rp_hierarchy_module' flag is set to False")
309+
310+
parser.addini(
311+
'retries',
312+
default='0',
313+
help='Amount of retries for performing REST calls to RP server')

pytest_reportportal/rp_logging.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ def _log(self, level, msg, args,
4444
record = self.makeRecord(self.name, level, fn, lno, msg, args,
4545
exc_info, func, extra, sinfo)
4646

47-
record.attachment = attachment
47+
if not record.attachment:
48+
record.attachment = attachment
4849
self.handle(record)
4950

5051

pytest_reportportal/service.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ def __init__(self):
7777
self._item_parts = {}
7878

7979
def init_service(self, endpoint, project, uuid, log_batch_size,
80-
ignore_errors, ignored_tags, verify_ssl=True):
80+
ignore_errors, ignored_tags, verify_ssl=True,
81+
retries=0):
8182
self._errors = queue.Queue()
8283
if self.RP is None:
8384
self.ignore_errors = ignore_errors
@@ -92,10 +93,14 @@ def init_service(self, endpoint, project, uuid, log_batch_size,
9293
project=project,
9394
token=uuid,
9495
error_handler=self.async_error_handler,
96+
retries=retries,
9597
log_batch_size=log_batch_size # ,
9698
# verify_ssl=verify_ssl
9799
)
98-
self.project_settiings = None # self.RP.rp_client.get_project_settings() if self.RP else None
100+
if self.RP and hasattr(self.RP.rp_client, "get_project_settings"):
101+
self.project_settiings = self.RP.rp_client.get_project_settings()
102+
else:
103+
self.project_settiings = None
99104
self.issue_types = self.get_issue_types()
100105
else:
101106
log.debug('The pytest is already initialized')

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def read_file(fname):
2525
version=version,
2626
description='Agent for Reporting results of tests to the Report Portal',
2727
long_description=read_file('README.rst'),
28+
long_description_content_type='text/markdown',
2829
author='Pavel Papou',
2930
author_email='[email protected]',
3031
url='https://github.com/reportportal/agent-python-pytest',

0 commit comments

Comments
 (0)