Skip to content

Commit 3395cf9

Browse files
committed
Revert "xdist fix"
This reverts commit ab499fa.
1 parent ab499fa commit 3395cf9

File tree

5 files changed

+35
-51
lines changed

5 files changed

+35
-51
lines changed

pytest_reportportal/listener.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import pytest
33
import logging
44

5+
from .service import PyTestService
56

67
try:
78
# This try/except can go away once we support pytest >= 3.3
@@ -13,17 +14,16 @@
1314

1415

1516
class RPReportListener(object):
16-
def __init__(self, py_test_service, log_level=logging.NOTSET):
17+
def __init__(self, log_level=logging.NOTSET):
1718
# Test Item result
18-
self.PyTestService = py_test_service
1919
self.result = None
2020
self._log_level = log_level
2121
if PYTEST_HAS_LOGGING_PLUGIN:
2222
self._log_handler = RPLogHandler(log_level, filter_reportportal_client_logs=True)
2323

2424
@pytest.hookimpl(hookwrapper=True)
2525
def pytest_runtest_protocol(self, item):
26-
self.PyTestService.start_pytest_item(item)
26+
PyTestService.start_pytest_item(item)
2727
if PYTEST_HAS_LOGGING_PLUGIN:
2828
# This check can go away once we support pytest >= 3.3
2929
with patching_logger_class():
@@ -32,14 +32,14 @@ def pytest_runtest_protocol(self, item):
3232
yield
3333
else:
3434
yield
35-
self.PyTestService.finish_pytest_item(self.result or 'SKIPPED')
35+
PyTestService.finish_pytest_item(self.result or 'SKIPPED')
3636

3737
@pytest.hookimpl(hookwrapper=True)
3838
def pytest_runtest_makereport(self):
3939
report = (yield).get_result()
4040

4141
if report.longrepr:
42-
self.PyTestService.post_log(
42+
PyTestService.post_log(
4343
# Used for support python 2.7
4444
cgi.escape(report.longreprtext),
4545
loglevel='ERROR',

pytest_reportportal/plugin.py

Lines changed: 22 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
# and/or modify it under the terms of the GPL licence
33

44
import logging
5-
import dill as pickle
6-
import pytest
7-
from .service import PyTestServiceClass
5+
6+
from .service import PyTestService
87
from .listener import RPReportListener
98

109
try:
@@ -15,38 +14,24 @@
1514
PYTEST_HAS_LOGGING_PLUGIN = False
1615

1716

18-
def is_master(config):
19-
"""
20-
True if the code running the given pytest.config object is running in a xdist master
21-
node or not running xdist at all.
22-
"""
23-
return not hasattr(config, 'slaveinput')
24-
25-
26-
@pytest.mark.optionalhook
27-
def pytest_configure_node(node):
28-
node.slaveinput['py_test_service'] = pickle.dumps(node.config.py_test_service)
29-
30-
3117
def pytest_sessionstart(session):
3218
if session.config.getoption('--collect-only', default=False) is True:
3319
return
3420

35-
if is_master(session.config):
36-
session.config.py_test_service.init_service(
37-
project=session.config.getini('rp_project'),
38-
endpoint=session.config.getini('rp_endpoint'),
39-
uuid=session.config.getini('rp_uuid'),
40-
log_batch_size=int(session.config.getini('rp_log_batch_size')),
41-
ignore_errors=bool(session.config.getini('rp_ignore_errors')),
42-
ignored_tags=session.config.getini('rp_ignore_tags'),
43-
)
21+
PyTestService.init_service(
22+
project=session.config.getini('rp_project'),
23+
endpoint=session.config.getini('rp_endpoint'),
24+
uuid=session.config.getini('rp_uuid'),
25+
log_batch_size=int(session.config.getini('rp_log_batch_size')),
26+
ignore_errors=bool(session.config.getini('rp_ignore_errors')),
27+
ignored_tags=session.config.getini('rp_ignore_tags'),
28+
)
4429

45-
session.config.py_test_service.start_launch(
46-
session.config.option.rp_launch,
47-
tags=session.config.getini('rp_launch_tags'),
48-
description=session.config.getini('rp_launch_description'),
49-
)
30+
PyTestService.start_launch(
31+
session.config.option.rp_launch,
32+
tags=session.config.getini('rp_launch_tags'),
33+
description=session.config.option.rp_launch_description,
34+
)
5035

5136

5237
def pytest_sessionfinish(session):
@@ -55,8 +40,7 @@ def pytest_sessionfinish(session):
5540

5641
# FixMe: currently method of RP api takes the string parameter
5742
# so it is hardcoded
58-
if is_master(session.config):
59-
session.config.py_test_service.finish_launch(status='RP_Launch')
43+
PyTestService.finish_launch(status='RP_Launch')
6044

6145

6246
def pytest_configure(config):
@@ -65,33 +49,30 @@ def pytest_configure(config):
6549
if not config.option.rp_launch_description:
6650
config.option.rp_launch_description = config.getini('rp_launch_description')
6751

68-
if is_master(config):
69-
config.py_test_service = PyTestServiceClass()
70-
else:
71-
config.py_test_service = pickle.loads(config.slaveinput['py_test_service'])
72-
config.py_test_service.RP.listener.start()
52+
if config.pluginmanager.hasplugin('xdist'):
53+
raise Exception(
54+
"pytest report portal is not compatible with 'xdist' plugin.")
7355

7456
# set Pytest_Reporter and configure it
7557

7658
if PYTEST_HAS_LOGGING_PLUGIN:
7759
# This check can go away once we support pytest >= 3.3
7860
try:
7961
config._reporter = RPReportListener(
80-
config.py_test_service,
8162
_pytest.logging.get_actual_log_level(config, 'rp_log_level')
8263
)
8364
except TypeError:
8465
# No log level set either in INI or CLI
85-
config._reporter = RPReportListener(config.py_test_service)
66+
config._reporter = RPReportListener()
8667
else:
87-
config._reporter = RPReportListener(config.py_test_service)
68+
config._reporter = RPReportListener()
8869

8970
if hasattr(config, '_reporter'):
9071
config.pluginmanager.register(config._reporter)
9172

9273

9374
def pytest_unconfigure(config):
94-
config.py_test_service.terminate_service()
75+
PyTestService.terminate_service()
9576

9677
if hasattr(config, '_reporter'):
9778
reporter = config._reporter

pytest_reportportal/rp_logging.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
from functools import wraps
55
from six import PY2
66

7+
from .service import PyTestService
8+
79

810
class RPLogger(logging.getLoggerClass()):
911
def __init__(self, name, level=0):
@@ -60,11 +62,10 @@ class RPLogHandler(logging.Handler):
6062
}
6163
_sorted_levelnos = sorted(_loglevel_map.keys(), reverse=True)
6264

63-
def __init__(self, py_test_service, level=logging.NOTSET,
65+
def __init__(self, level=logging.NOTSET,
6466
filter_reportportal_client_logs=False):
6567
super(RPLogHandler, self).__init__(level)
6668
self.filter_reportportal_client_logs = filter_reportportal_client_logs
67-
self.py_test_service = py_test_service
6869

6970
def filter(self, record):
7071
if self.filter_reportportal_client_logs is False:
@@ -89,7 +90,7 @@ def emit(self, record):
8990
if level <= record.levelno:
9091
break
9192

92-
return self.py_test_service.post_log(
93+
return PyTestService.post_log(
9394
msg,
9495
loglevel=self._loglevel_map[level],
9596
attachment=record.__dict__.get('attachment', None),

pytest_reportportal/service.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,6 @@ def _get_description(test_item):
179179
except AttributeError:
180180
# doctest has no `function` attribute
181181
return test_item.reportinfo()[2]
182+
183+
184+
PyTestService = PyTestServiceClass()

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ def read_file(fname):
1212

1313

1414
requirements = [
15-
'reportportal-client>=3.0.1',
15+
'reportportal-client>=3.0.0',
1616
'pytest>=3.0.7',
1717
'six>=1.10.0',
18-
'dill>=0.2.7.1',
1918
]
2019

2120

0 commit comments

Comments
 (0)