Skip to content

Commit f4935cf

Browse files
committed
Add rp_display_suite_test_file to pytest.ini flags
Add the rp_display_suite_test_file twick which is relevant only when "rp_hierarchy_module" flag is False Disable the verify_ssl from the init_service from PyTestServiceClass class Edit the collect_tests of PyTestServiceClass to support the new display_suite_file_name twick
1 parent 0621971 commit f4935cf

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

pytest_reportportal/plugin.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,3 +297,10 @@ def pytest_addoption(parser):
297297
default=True,
298298
type='bool',
299299
help='Verify HTTPS calls')
300+
301+
parser.addini(
302+
'rp_display_suite_test_file',
303+
default=True,
304+
type='bool',
305+
help='Displays the test file of the suite as a convention of "file::suite" - relevant only when '
306+
'"rp_hierarchy_module" flag is False')

pytest_reportportal/service.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
import logging
22
import sys
33
import traceback
4-
import pytest
5-
import pkg_resources
6-
74
from time import time
8-
from six import with_metaclass
9-
from six.moves import queue
105

11-
from _pytest.main import Session
12-
from _pytest.python import Class, Function, Instance, Module
6+
import pkg_resources
7+
import pytest
138
from _pytest.doctest import DoctestItem
9+
from _pytest.main import Session
1410
from _pytest.nodes import File, Item
11+
from _pytest.python import Class, Function, Instance, Module
1512
from _pytest.unittest import TestCaseFunction, UnitTestCase
1613
from reportportal_client import ReportPortalServiceAsync
14+
from six import with_metaclass
15+
from six.moves import queue
1716

1817
log = logging.getLogger(__name__)
1918

@@ -92,10 +91,10 @@ def init_service(self, endpoint, project, uuid, log_batch_size,
9291
project=project,
9392
token=uuid,
9493
error_handler=self.async_error_handler,
95-
log_batch_size=log_batch_size,
96-
verify_ssl=verify_ssl
94+
log_batch_size=log_batch_size # ,
95+
# verify_ssl=verify_ssl
9796
)
98-
self.project_settiings = self.RP.rp_client.get_project_settings() if self.RP else None
97+
self.project_settiings = None # self.RP.rp_client.get_project_settings() if self.RP else None
9998
self.issue_types = self.get_issue_types()
10099
else:
101100
log.debug('The pytest is already initialized')
@@ -130,7 +129,6 @@ def start_launch(self, launch_name,
130129
req_data = self.RP.start_launch(**sl_pt)
131130
log.debug('ReportPortal - Launch started: response_body=%s', req_data)
132131

133-
134132
def collect_tests(self, session):
135133
self._stop_if_necessary()
136134
if self.RP is None:
@@ -140,12 +138,14 @@ def collect_tests(self, session):
140138
hier_module = False
141139
hier_class = False
142140
hier_param = False
141+
display_suite_file_name = True
143142

144143
if not hasattr(session.config, 'slaveinput'):
145144
hier_dirs = session.config.getini('rp_hierarchy_dirs')
146145
hier_module = session.config.getini('rp_hierarchy_module')
147146
hier_class = session.config.getini('rp_hierarchy_class')
148147
hier_param = session.config.getini('rp_hierarchy_parametrize')
148+
display_suite_file_name = session.config.getini('rp_display_suite_test_file')
149149

150150
try:
151151
hier_dirs_level = int(session.config.getini('rp_hierarchy_dirs_level'))
@@ -181,6 +181,8 @@ def collect_tests(self, session):
181181

182182
self._item_parts[item] = parts
183183
for part in parts:
184+
if '_pytest.python.Class' in str(type(part)) and not display_suite_file_name and not hier_module:
185+
part._rp_name = part._rp_name.split("::")[-1]
184186
if part not in self._hier_parts:
185187
self._hier_parts[part] = {"finish_counter": 1, "start_flag": False}
186188
else:
@@ -249,7 +251,6 @@ def finish_pytest_item(self, test_item, status, issue=None):
249251
log.debug('ReportPortal - End TestSuite: request_body=%s', payload)
250252
self.RP.finish_test_item(**payload)
251253

252-
253254
def finish_launch(self, launch=None, status='rp_launch'):
254255
self._stop_if_necessary()
255256
if self.RP is None:
@@ -347,7 +348,8 @@ def _add_item_hier_parts_parametrize(item, report_parts, tests_parts, rp_name=""
347348
if test_fullname in tests_parts:
348349
item_test = tests_parts[test_fullname]
349350
else:
350-
item_test = Item(test_fullname, nodeid=test_fullname, session=item.session, config=item.session.config)
351+
item_test = Item(test_fullname, nodeid=test_fullname, session=item.session,
352+
config=item.session.config)
351353
item_test._rp_name = rp_name
352354
item_test.obj = item.obj
353355
item_test.keywords = item.keywords

0 commit comments

Comments
 (0)