Skip to content

Commit 8927e8e

Browse files
author
Dzmitry Humianiuk
authored
Merge pull request #119 from bigbZik/client-fix
Getting project settings if client support it
2 parents fffe4d6 + 3929053 commit 8927e8e

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
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/service.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ def init_service(self, endpoint, project, uuid, log_batch_size,
9494
log_batch_size=log_batch_size # ,
9595
# verify_ssl=verify_ssl
9696
)
97-
self.project_settiings = None # self.RP.rp_client.get_project_settings() if self.RP else None
97+
if self.RP and hasattr(self.RP.rp_client, "get_project_settings"):
98+
self.project_settiings = self.RP.rp_client.get_project_settings()
99+
else:
100+
self.project_settiings = None
98101
self.issue_types = self.get_issue_types()
99102
else:
100103
log.debug('The pytest is already initialized')

0 commit comments

Comments
 (0)