Giter VIP home page Giter VIP logo

agent-python-pytest's Introduction

agent-python-pytest

Latest Version

Supported python versions

Test status

Test coverage

Join Slack chat!

Pytest plugin for reporting test results of the Pytest to the ReportPortal.

Installation

To install pytest plugin execute next command in a terminal:

pip install pytest-reportportal

Look through the CONTRIBUTING.rst for contribution guidelines.

Configuration

Prepare the config file pytest.ini in root directory of tests or specify any one using pytest command line option:

py.test -c config.cfg

The pytest.ini file should have next mandatory fields:

  • rp_api_key - value could be found in the User Profile section
  • rp_project - name of project in ReportPortal
  • rp_endpoint - address of ReportPortal Server

Example of pytest.ini:

[pytest]
rp_api_key = fb586627-32be-47dd-93c1-678873458a5f
rp_endpoint = http://192.168.1.10:8080
rp_project = user_personal
rp_launch = AnyLaunchName
rp_launch_attributes = 'PyTest' 'Smoke'
rp_launch_description = 'Smoke test'
rp_ignore_attributes = 'xfail' 'usefixture'
  • The rp_api_key can also be set with the environment variable RP_API_KEY. This will override the value set for rp_api_key in pytest.ini

There are also optional parameters: https://reportportal.io/docs/log-data-in-reportportal/test-framework-integration/Python/pytest/

Examples

For logging of the test item flow to ReportPortal, please, use the python logging handler provided by plugin like bellow:

in conftest.py:

import logging
import sys

import pytest

from reportportal_client import RPLogger


@pytest.fixture(scope="session")
def rp_logger():
    logger = logging.getLogger(__name__)
    logger.setLevel(logging.DEBUG)
    logging.setLoggerClass(RPLogger)
    return logger

in tests:

# In this case only INFO messages will be sent to the ReportPortal.
def test_one(rp_logger):
    rp_logger.info("Case1. Step1")
    x = "this"
    rp_logger.info("x is: %s", x)
    assert 'h' in x

    # Message with an attachment.
    import subprocess
    free_memory = subprocess.check_output("free -h".split())
    rp_logger.info(
        "Case1. Memory consumption",
        attachment={
            "name": "free_memory.txt",
            "data": free_memory,
            "mime": "application/octet-stream",
        },
    )

    # This debug message will not be sent to the ReportPortal.
    rp_logger.debug("Case1. Debug message")

Launching

To run test with ReportPortal you must provide '--reportportal' flag:

py.test ./tests --reportportal

Check the documentation to find more detailed information about how to integrate pytest with ReportPortal using an agent: https://reportportal.io/docs/log-data-in-reportportal/test-framework-integration/Python/pytest/

Licensed under the Apache 2.0 license (see the LICENSE file).

agent-python-pytest's People

Contributors

ailjushkin avatar avarabyeu avatar bigbzik avatar ch-t avatar dagansandler avatar ehaelyon avatar el0ny avatar filland avatar frizzby avatar hardnorth avatar iivanou avatar jmoravec avatar kevin-henry-fernride avatar kkoukiou avatar kleptog avatar krasoffski avatar mbroton avatar pressayuliya avatar pshv avatar raikbitters avatar ramriddick avatar rplevka avatar rthardin avatar s0undt3ch avatar san7ket avatar surevs avatar vakulich avatar vkolgi avatar vstoilovskyi avatar yakovbabich avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

agent-python-pytest's Issues

install the agent from git return unexpected keyword argument verify_ssl error

step to reproduce

  1. Install the agent from the current git (1.0.4)
  2. ran tests
pytest project-tests\tests\suit_basic_tests.py --reportportal
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "c:\users\myuser\appdata\local\programs\python\python36-32\lib\site-packages\_pytest\main.py", line 207, in wrap_session
INTERNALERROR>     config.hook.pytest_sessionstart(session=session)
INTERNALERROR>   File "c:\users\myuser\appdata\local\programs\python\python36-32\lib\site-packages\pluggy\hooks.py", line 289, in __call__
INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR>   File "c:\users\myuser\appdata\local\programs\python\python36-32\lib\site-packages\pluggy\manager.py", line 68, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "c:\users\myuser\appdata\local\programs\python\python36-32\lib\site-packages\pluggy\manager.py", line 62, in <lambda>
INTERNALERROR>     firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
INTERNALERROR>   File "c:\users\myuser\appdata\local\programs\python\python36-32\lib\site-packages\pluggy\callers.py", line 208, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "c:\users\myuser\appdata\local\programs\python\python36-32\lib\site-packages\pluggy\callers.py", line 80, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "c:\users\myuser\appdata\local\programs\python\python36-32\lib\site-packages\pluggy\callers.py", line 187, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "c:\users\myuser\appdata\local\programs\python\python36-32\lib\site-packages\pytest_reportportal\plugin.py", line 57, in pytest_sessionstart
INTERNALERROR>     verify_ssl=session.config.getini('rp_verify_ssl')
INTERNALERROR>   File "c:\users\myuser\appdata\local\programs\python\python36-32\lib\site-packages\pytest_reportportal\service.py", line 96, in init_service
INTERNALERROR>     verify_ssl=verify_ssl
INTERNALERROR> TypeError: __init__() got an unexpected keyword argument 'verify_ssl'```

Enable implicit plugin usage by using a `--reportportal` flag

Instead of activation the plugin by default and using pytest's disable plugin ability to shut it down, it would be nicer to enable it explicitly by sending a --reportportal flag:
pytest tests --reportportal
Which can also be used in the pytets.ini files:

[pytest]
addopts: --reportportal

If i'll have the time I'll try to push a PR with this change myself

Unable to run example test using Python 2.7.12

Steps for reproduce:

  1. Following steps from README.rst install pip install pytest_reportportal.
  2. Than create sample_test.py from readme file and pytest.ini configuration file.
  3. Run test with command pytest sample_test.py.

There are no any issues with Python3. But with Python2 you might get following issue:

 $ pytest sample_test.py 
=============================== test session starts ================================
platform linux2 -- Python 2.7.12, pytest-3.2.0, py-1.5.2, pluggy-0.4.0
rootdir: /ReportPoral, inifile: pytest.ini
plugins: reportportal-1.0.1
collected 1 item s

sample_test.py F

===================================== FAILURES =====================================
_____________________________________ test_one _____________________________________

    def test_one():
>       logger.info("Case1. Step1")

sample_test.py:18: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib/python2.7/logging/__init__.py:1167: in info
    self._log(INFO, msg, args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <pytest_reportportal.rp_logging.RPLogger object at 0x7f31745b5c10>
level = 20, msg = 'Case1. Step1', args = (), exc_info = None, extra = None
stack_info = False, attachment = None

    def _log(self, level, msg, args,
             exc_info=None, extra=None, stack_info=False, attachment=None):
        """
            Low-level logging routine which creates a LogRecord and then calls
            all the handlers of this logger to handle the record.
            """
        sinfo = None
        if logging._srcfile:
            # IronPython doesn't track Python frames, so findCaller raises an
            # exception on some versions of IronPython. We trap it here so that
            # IronPython can use logging.
            try:
>               fn, lno, func, sinfo = self.findCaller(stack_info)
E               TypeError: findCaller() takes exactly 1 argument (2 given)

agent-python-pytest/pytest_reportportal/rp_logging.py:23: TypeError
============================= 1 failed in 0.07 seconds =============================

The root cause is obvious - different semantics of internal logging methods.
Need to investigate changes which lead to this problem.

Support for rp_mode

As per the documentation in http://reportportal.io/docs/How-to-avoid providing rp.mode=debug will avoid local execution reported in project space. However, when I use this option it doesn't work and the execution is reported in project space instead of 'Debug' section of project space.

Uploading of test results should be done after the test run

So far, I have not been able to use pytest-reportportal agent successfully. After thorough investigation, I noticed that our testsuite uses patch in a few cases for builtin.open and requests library. When this is done, it has an impact on the workings of the async RP service object which pushes results to the server.

To work around this, pushing the results should only be done after the test suite has ran and all the patch setups are cleaned up.

rp_ignore_errors doesn't apply on session start

if there is some issue with the report portal from the very beginning (not reachable, access denied, etc.),
the rp_ignore_errors does not stop the py.test from crashing miserably.

the plugin.py hook: pytest_sessionstart(session) initializes the service (session.config.py_test_service.init_service())

and calls its start_launch() straight away. - one could possibly catch the HTTP error exception at this point and call pytest_unconfigure(session.config), but this does not throw the exception straight away since it calls some async method (it just adds it to the queue).

Include feature to exclude pytest marks

Hi, during tests automation I've faced with small problem - all pytest marks are send to report portal as tags.
It's really useful feature but sometimes I use marks which I don't want to sent to RP:
@pytest.mark.skip
@pytest.mark.usefixtures
@pytest.mark.xfail
and etc.

Could you think about this improvement?
Maybe it will be helpfull to add additional option in pytest.ini like rp_ignore_tags

[regression] pytest now crashes if pytest-xdist is used

this got introduced by
d625655

INTERNALERROR>   File "/home/rplevka/work/rplevka/agent-python-pytest/pytest_reportportal/listener.py", line 32, in pytest_runtest_protocol
INTERNALERROR>     self.PyTestService.start_pytest_item(item)
INTERNALERROR>   File "/home/rplevka/work/rplevka/agent-python-pytest/pytest_reportportal/service.py", line 202, in start_pytest_item
INTERNALERROR>     part = self._start_stack.pop(0)
INTERNALERROR> IndexError: pop from empty list
    def start_pytest_item(self, test_item=None):
        self._stop_if_necessary()
        print(test_item)
        print(self._start_stack)
        if self.RP is None:
            return

        while True:
            part = self._start_stack.pop(0)                    #<- apparently this is mepty from the beginning, as the collect_tests seems to be skipped
            if part is test_item:
                break
            payload = { 
                'name': self._get_item_name(part),
                'description': self._get_item_description(part),
                'tags': self._get_item_tags(part),
                'start_time': timestamp(),
                'item_type': 'SUITE'
            }
            log.debug('ReportPortal - Start Suite: request_body=%s', payload)
            self.RP.start_test_item(**payload)
....

AttributeError: 'Module' object has no attribute 'get_marker'

System Version: macOS 10.14.2

test_calc.py:

from calc import Calc
class TestCalc(object):
    def test_plus(self):
        assert Calc().plus(2, 3) == 5

    def test_minus(self):
        assert Calc().minus(2, 3) == 5

pytest.ini:

[pytest]
rp_uuid = 2596195c-e886-4fac-a107-5751113b7cc2
rp_endpoint = http://localhost:8080
rp_project = test-poc
rp_launch = regression

Error:

platform darwin -- Python 3.7.2, pytest-4.1.1, py-1.7.0, pluggy-0.8.1
rootdir: /Users/visko/PycharmProjects/test-poc, inifile: pytest.ini
plugins: reportportal-1.0.4
collected 2 items
...
INTERNALERROR>   File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pytest_reportportal/listener.py", line 32, in pytest_runtest_protocol
INTERNALERROR>     self.PyTestService.start_pytest_item(item)
INTERNALERROR>   File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pytest_reportportal/service.py", line 200, in start_pytest_item
INTERNALERROR>     'tags': self._get_item_tags(part),
INTERNALERROR>   File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pytest_reportportal/service.py", line 416, in _get_item_tags
INTERNALERROR>     tags = [k for k in item.keywords if item.get_marker(k) is not None
INTERNALERROR>   File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pytest_reportportal/service.py", line 416, in <listcomp>
INTERNALERROR>     tags = [k for k in item.keywords if item.get_marker(k) is not None
INTERNALERROR> AttributeError: 'Module' object has no attribute 'get_marker'

The test run (launch) is added to RP, but there are no test cases or results added (total 0). It is supposed to be a very simple basic setup.
Could you please check?

Several launches are created for each process when tests are running in parallel with xdist library

Example of test:

import logging
from pytest_reportportal import RPLogger, RPLogHandler

logging.setLoggerClass(RPLogger)
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
# Create handler for Report Portal.
rp_handler = RPLogHandler()
# Set INFO level for Report Portal handler.
rp_handler.setLevel(logging.INFO)
# Set formatter.
formatter = logging.Formatter('%(asctime)s: - %(levelname)s - %(name)s: %(message)s',
                                        datefmt='%m/%d/%Y %I:%M:%S %p')
rp_handler.setFormatter(formatter)
# Add handler to the logger.
logger.addHandler(rp_handler)


def test_RP():
    assert True == True

def test_RP2():
    assert True == False

Run:

C:\Users\...\PycharmProjects\testRP>py.test -n 2 -v -s  test_Parallel.py  --rp-launch TestRPIssue
============================= test session starts =============================
platform win32 -- Python 3.5.2, pytest-3.1.2, py-1.4.34, pluggy-0.4.0 -- c:\users\...\appdata\local\programs\python\python35-32\python.exe
cachedir: .cache
rootdir: C:\Users\...\PycharmProjects\testRP, inifile: pytest.ini
plugins: pycharm-0.4.0, ordering-0.5, reportportal-1.0.0, xdist-1.18.0
[gw0] win32 Python 3.5.2 cwd: C:\Users\...\PycharmProjects\testRP
[gw1] win32 Python 3.5.2 cwd: C:\Users\...\PycharmProjects\testRP
[gw0] Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:01:18) [MSC v.1900 32 bit (Intel)]
[gw1] Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:01:18) [MSC v.1900 32 bit (Intel)]
gw0 [2] / gw1 [2]
scheduling tests via LoadScheduling

test_Parallel.py::test_RP
test_Parallel.py::test_RP2
[gw1] PASSED test_Parallel.py::test_RP
[gw0] FAILED test_Parallel.py::test_RP2

================================== FAILURES ===================================
__________________________________ test_RP2 ___________________________________
[gw0] win32 -- Python 3.5.2 c:\users\...\appdata\local\programs\python\python35-32\python.exe

    def test_RP2():
>       assert True == False
E       assert True == False

test_Parallel.py:23: AssertionError
===================== 1 failed, 1 passed in 1.72 seconds ======================


Results in report portal:

image

3 different launches were created. I think - first during initialization, second and third for each thread with test.

Report Portal client fail to find that a test is running

Hi,

RP client failed to find a test is running. however, with using -p no:pytest_reportportal, the tests works.
my test setup combined from an external parameters I'm pushing and conftest is parsing it.

Any idea what shall I do next?

--EDIT--
I see that the options loaded happnes after the plugin is loaded, that's why It's not getting to the point where it could parse the object I'm sending in as a mandatory part.

Nested hierarchy test items is hardcoded to standard pytest python/unittest

For a customer, I wrote 2 custom pytest plugins. Each of these plugins contain custom Python subclasses of pytest.File, pytest.Collector and pytest.Item to create a nested tree of test suites and tests.

When using pytest-reportportal, this nested structure is flattened in ReportPortal. When looking at the code, I see explicit references to pytest.Class, pytest.Function and alike in the support for nesting. This limits the nesting only to pytests using the standard python or unittest plugins.

Please make pytest-reportportal agnostic to which plugin(s) generate test items: you should process the tree as returned by any possible pytest plugin.

Note: IDEs like PyCharm show the nested hierarcy returned by my pytest plugins correctly.

Create quality gate for repository

Goal:

Automatic checks for new pull requests.

Tasks:

  • Add tests folder with several unit tests with mock class
  • Add test runner script which prepares environment and runs all tests
  • Update travis.yml

Tests:

  • Create launch test: check whether new launch created or not
  • Log Test test: check whether current test is logged in report portal
  • Log message test: check whether log contains some custom log message

Environment preparation:

  • download reportportal docker-compose file
  • docker-compose up -d
  • install requirements.txt (reportportal client, etc.)
  • run tests with reportportal integration

pip install doesn't work

Tried to install using pip install got an error:

Collecting pytest-reportportal
  Could not find a version that satisfies the requirement pytest-reportportal (from versions: )
No matching distribution found for pytest-reportportal

attachments do not get created from 2nd and subsequent tests

I am trying to use the attachment feature to attach a few log files. When I start my test run, I see attachment getting created in the first test. However, from second test onwards I see an error:
_log() got an unexpected keyword argument 'attachment'

Following is the code snippet I am trying:

def _set_portal_logging(service):
    """
    Report portal logger
    """
    logging.setLoggerClass(RPLogger)
    logger = logging.getLogger()
    logger.setLevel(logging.INFO)
    rp_handler = RPLogHandler(service)
    rp_handler.setLevel(logging.INFO)
    # logger.addHandler(rp_handler)
    return logger

@pytest.fixture(scope='function')
def ips_oprofile_reports(request, module_setup, commandline_args):
    """
    Fixture for downloading oprofile reports from
    oprofile server and attaching it to report portal
    logs
    """
    _set_portal_logging(request.node.config.py_test_service)
    args = commandline_args
    ips_api = ips_module_setup
    yield
    if ips_api.result is False:
        logging.info("Test failed in ixload configuration")
    else:
       for file in report_list:
                try:
                    content = profile.download_report_file(id, file)
                    if len(content) < 1:
                        continue
                    logging.info("attaching file {}_{}".format(file, id),
                                attachment={"name": '{}_{}'.format(file, id),
                                            "data": content,
                                            "mime": "application/octet-stream",}
                                ,)
                except Exception as e:
                    logging.info(e)
                    continue

[SSL: CERTIFICATE_VERIFY_FAILED] with flag "rp_verify_ssl = False"

introduced by cb3e447
STR.

  1. use RP server with ssl support
  2. use agent-python-pytest without valid cert and with flag rp_verify_ssl = False
  3. launch tests
    ER.
  4. Launch started no failures related to ssl verification
    AR.
  5. (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:847)')
    code which causing error and ignore ssl verify flag:
    INTERNALERROR> self.project_settiings = self.RP.rp_client.get_project_settings() if self.RP else None
    INTERNALERROR> File "c:\users**.virtualenvs*\src\reportportal-client\reportportal_client\service.py", line 230, in get_project_settings
    INTERNALERROR> r = self.session.get(url=url, json={})

Unable to run py.test without having pytest_reportportal configured once installed

what i'm looking for here is to make the report_portal logger optional - however, once the plugin gets installed, one is unable to run py.test without having configured pytest.ini (or options passed by -o rp_*=value).
The pytests fails with:

INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/home/rplevka/.virtualenvs/master_robottelo_p3/lib/python3.6/site-packages/_pytest/main.py", line 176, in wrap_session
INTERNALERROR>     config.hook.pytest_sessionstart(session=session)
INTERNALERROR>   File "/home/rplevka/.virtualenvs/master_robottelo_p3/lib/python3.6/site-packages/pluggy/__init__.py", line 617, in __call__
INTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "/home/rplevka/.virtualenvs/master_robottelo_p3/lib/python3.6/site-packages/pluggy/__init__.py", line 222, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/home/rplevka/.virtualenvs/master_robottelo_p3/lib/python3.6/site-packages/pluggy/__init__.py", line 216, in <lambda>
INTERNALERROR>     firstresult=hook.spec_opts.get('firstresult'),
INTERNALERROR>   File "/home/rplevka/.virtualenvs/master_robottelo_p3/lib/python3.6/site-packages/pluggy/callers.py", line 201, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/home/rplevka/.virtualenvs/master_robottelo_p3/lib/python3.6/site-packages/pluggy/callers.py", line 76, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/home/rplevka/.virtualenvs/master_robottelo_p3/lib/python3.6/site-packages/pluggy/callers.py", line 180, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/home/rplevka/.virtualenvs/master_robottelo_p3/lib/python3.6/site-packages/pytest_reportportal/plugin.py", line 53, in pytest_sessionstart
INTERNALERROR>     wait_launch(session.config.py_test_service.RP.rp_client)
INTERNALERROR>   File "/home/rplevka/.virtualenvs/master_robottelo_p3/lib/python3.6/site-packages/pytest_reportportal/plugin.py", line 60, in wait_launch
INTERNALERROR>     raise Exception("Launch not found")
INTERNALERROR> Exception: Launch not found
  • I'm not initializing the logger anywhere in my code, it's just the presence of the plugin.
  • I would expect the plugin skips configuring if it can't find some vital configuration options (e.g. endpoint).

rp_ignore_errors doesn't ignore connection issues

For example reporpotral server is down and we have rp_ignore_errors = True and rp_verify_ssl = False into pytest.ini.
We have an error like this:

INTERNALERROR>   File "/home/akropyva/Projects/apx-qa-tests/venv/lib/python3.7/site-packages/pytest_reportportal/plugin.py", line 57, in pytest_sessionstart
INTERNALERROR>     verify_ssl=session.config.getini('rp_verify_ssl')
INTERNALERROR>   File "/home/akropyva/Projects/apx-qa-tests/venv/lib/python3.7/site-packages/pytest_reportportal/service.py", line 98, in init_service
INTERNALERROR>     self.project_settiings = self.RP.rp_client.get_project_settings() if self.RP else None
INTERNALERROR>   File "/home/akropyva/Projects/apx-qa-tests/venv/src/reportportal-client/reportportal_client/service.py", line 230, in get_project_settings
INTERNALERROR>     r = self.session.get(url=url, json={}, verify=self.verify_ssl)
INTERNALERROR>   File "/home/akropyva/Projects/apx-qa-tests/venv/lib/python3.7/site-packages/requests/sessions.py", line 546, in get
INTERNALERROR>     return self.request('GET', url, **kwargs)
INTERNALERROR>   File "/home/akropyva/Projects/apx-qa-tests/venv/lib/python3.7/site-packages/requests/sessions.py", line 533, in request
INTERNALERROR>     resp = self.send(prep, **send_kwargs)
INTERNALERROR>   File "/home/akropyva/Projects/apx-qa-tests/venv/lib/python3.7/site-packages/requests/sessions.py", line 646, in send
INTERNALERROR>     r = adapter.send(request, **kwargs)
INTERNALERROR>   File "/home/akropyva/Projects/apx-qa-tests/venv/lib/python3.7/site-packages/requests/adapters.py", line 516, in send
INTERNALERROR>     raise ConnectionError(e, request=request)
INTERNALERROR> requests.exceptions.ConnectionError: HTTPSConnectionPool(host='reportposrtal.apixio.com', port=443): Max retries exceeded with url: /api/v1/vkushnarenko-apixio_personal/settings (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f6bd34ab748>: Failed to establish a new connection: [Errno -2] Name or service not known'))

init_service => get_project_settings => r = self.session.get(url=url, json={}, verify=self.verify_ssl) which causes an error past parameter rp_ignore_errors

reportportal_client.errors.Error: Service already stopped.

platform linux -- Python 3.5.2, pytest-3.1.2, py-1.4.34, pluggy-0.4.0
rootdir: /home/dkorytkin/my_work/marketplace, inifile: pytest.ini
plugins: reportportal-1.0.0, env-0.6.2
collected 7 items 

test_marketplace_catalog_main_page.py ..
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/main.py", line 105, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/main.py", line 141, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 745, in __call__
INTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 339, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 334, in <lambda>
INTERNALERROR>     _MultiCall(methods, kwargs, hook.spec_opts).execute()
INTERNALERROR>   File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 614, in execute
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/main.py", line 164, in pytest_runtestloop
INTERNALERROR>     item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR>   File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 745, in __call__
INTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 339, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 334, in <lambda>
INTERNALERROR>     _MultiCall(methods, kwargs, hook.spec_opts).execute()
INTERNALERROR>   File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 613, in execute
INTERNALERROR>     return _wrapped_call(hook_impl.function(*args), self.execute)
INTERNALERROR>   File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 254, in _wrapped_call
INTERNALERROR>     return call_outcome.get_result()
INTERNALERROR>   File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 279, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 265, in __init__
INTERNALERROR>     self.result = func()
INTERNALERROR>   File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 613, in execute
INTERNALERROR>     return _wrapped_call(hook_impl.function(*args), self.execute)
INTERNALERROR>   File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 254, in _wrapped_call
INTERNALERROR>     return call_outcome.get_result()
INTERNALERROR>   File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 279, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 265, in __init__
INTERNALERROR>     self.result = func()
INTERNALERROR>   File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 614, in execute
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/runner.py", line 60, in pytest_runtest_protocol
INTERNALERROR>     runtestprotocol(item, nextitem=nextitem)
INTERNALERROR>   File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/runner.py", line 75, in runtestprotocol
INTERNALERROR>     nextitem=nextitem))
INTERNALERROR>   File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/runner.py", line 129, in call_and_report
INTERNALERROR>     report = hook.pytest_runtest_makereport(item=item, call=call)
INTERNALERROR>   File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 745, in __call__
INTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 339, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 334, in <lambda>
INTERNALERROR>     _MultiCall(methods, kwargs, hook.spec_opts).execute()
INTERNALERROR>   File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 613, in execute
INTERNALERROR>     return _wrapped_call(hook_impl.function(*args), self.execute)
INTERNALERROR>   File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 250, in _wrapped_call
INTERNALERROR>     wrap_controller.send(call_outcome)
INTERNALERROR>   File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/pytest_reportportal/plugin.py", line 55, in pytest_runtest_makereport
INTERNALERROR>     PyTestService.finish_pytest_item(item_result)
INTERNALERROR>   File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/pytest_reportportal/service.py", line 116, in finish_pytest_item
INTERNALERROR>     self.RP.finish_test_item(**fta_rq)
INTERNALERROR>   File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/reportportal_client/service_async.py", line 256, in finish_test_item
INTERNALERROR>     self.queue.put_nowait(("finish_test_item", args))
INTERNALERROR> AttributeError: 'NoneType' object has no attribute 'put_nowait'
Traceback (most recent call last):
  File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/config.py", line 58, in main
    return config.hook.pytest_cmdline_main(config=config)
  File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 745, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 339, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 334, in <lambda>
    _MultiCall(methods, kwargs, hook.spec_opts).execute()
  File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 614, in execute
    res = hook_impl.function(*args)
  File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/main.py", line 134, in pytest_cmdline_main
    return wrap_session(config, _main)
  File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/main.py", line 128, in wrap_session
    exitstatus=session.exitstatus)
  File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 745, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 339, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 334, in <lambda>
    _MultiCall(methods, kwargs, hook.spec_opts).execute()
  File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 613, in execute
    return _wrapped_call(hook_impl.function(*args), self.execute)
  File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 250, in _wrapped_call
    wrap_controller.send(call_outcome)
  File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/terminal.py", line 386, in pytest_sessionfinish
    outcome.get_result()
  File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 279, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 265, in __init__
    self.result = func()
  File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 614, in execute
    res = hook_impl.function(*args)
  File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/pytest_reportportal/plugin.py", line 77, in pytest_sessionfinish
    PyTestService.finish_launch(status="RP_Launch")
  File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/pytest_reportportal/service.py", line 126, in finish_launch
    self.RP.finish_launch(**fl_rq)
  File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/reportportal_client/service_async.py", line 233, in finish_launch
    self.queue.put_nowait(("finish_launch", args))
AttributeError: 'NoneType' object has no attribute 'put_nowait'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/bin/pytest", line 11, in <module>
    sys.exit(main())
  File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/config.py", line 60, in main
    config._ensure_unconfigure()
  File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/config.py", line 917, in _ensure_unconfigure
    self.hook.pytest_unconfigure(config=self)
  File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 745, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 339, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 334, in <lambda>
    _MultiCall(methods, kwargs, hook.spec_opts).execute()
  File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 614, in execute
    res = hook_impl.function(*args)
  File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/pytest_reportportal/plugin.py", line 92, in pytest_unconfigure
    PyTestService.terminate_service()
  File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/pytest_reportportal/service.py", line 54, in terminate_service
    self.RP.terminate()
  File "/home/dkorytkin/.local/share/virtualenvs/marketplace-Gls_8Zt3/lib/python3.5/site-packages/reportportal_client/service_async.py", line 153, in terminate
    raise Error("Service already stopped.")
reportportal_client.errors.Error: Service already stopped.```

Failed run test with xdist

Problem
Run pytest + xdist with reportportal failed

How to reproduce?

I have follow files:

tests/test_report_portal.py

def test_RP1():
    assert True


def test_RP2():
    assert False

pytest.ini

[pytest]
rp_uuid = 4eb45953-d51d-42a5-9447-8082a24aa516
rp_endpoint = https://my.rp.address.ru
rp_project = my-rp-project

Run tests with xdist

pytest tests/test_report_portal.py --reportportal -n 3 

Actual result

pytest tests/test_report_portal.py --reportportal -n 3         
====================================================================================================== test session starts ======================================================================================================
platform darwin -- Python 3.6.5, pytest-3.6.0, py-1.5.3, pluggy-0.6.0
rootdir: /Users/user/git/myProject, inifile: pytest.ini
plugins: xdist-1.24.1, rerunfailures-4.2, reportportal-1.0.4, forked-1.0.2, allure-pytest-2.3.2b1
gw0 [12] / gw1 [12] / gw2 [12]
scheduling tests via LoadScheduling
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/_pytest/main.py", line 107, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/_pytest/main.py", line 145, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/pluggy/__init__.py", line 617, in __call__
INTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/pluggy/__init__.py", line 222, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/pluggy/__init__.py", line 216, in <lambda>
INTERNALERROR>     firsINTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/_pytest/main.py", line 107, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/_pytest/main.py", line 145, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/pluggy/__init__.py", line 617, in __call__
INTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/pluggy/__init__.py", line 222, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/pluggy/__init__.py", line 216, in <lambda>
INTERNALERROR>     firstresult=hook.spec_opts.get('firstresult'),
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/pluggy/callers.py", line 201, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/pluggy/callers.py", line 76, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/pluggy/callers.py", line 180, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "<remote exec>", line 66, in pytest_runtestloop
INTERNALERROR>   File "<remote exec>", line 83, in run_one_test
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/pluggy/__init__.py", line 617, in __call__
INTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/pluggy/__init__.py", line 222, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/pluggy/__init__.py", line 216, in <lambda>
INTERNALERROR>     firstresult=hook.spec_opts.get('firstresult'),
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/pluggy/callers.py", line 201, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/pluggy/callers.py", line 76, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/pluggy/callers.py", line 175, in _multicall
INTERNALERROR>     next(gen)   # first yield
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/pytest_reportportal/listener.py", line 32, in pytest_runtest_protocol
tresult=hook.spec_opts.get('firstresult'),
INTERNALERROR>     self.PyTestService.start_pytest_item(item)
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/pytest_reportportal/service.py", line 194, in start_pytest_item
INTERNALERROR>     part = self._start_stack.pop(0)
INTERNALERROR> IndexError: pop from empty list
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/pluggy/callers.py", line 201, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/pluggy/callers.py", line 76, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/pluggy/callers.py", line 180, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "<remote exec>", line 66, in pytest_runtestloop
INTERNALERROR>   File "<remote exec>", line 83, in run_one_test
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/pluggy/__init__.py", line 617, in __call__
INTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/pluggy/__init__.py", line 222, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/pluggy/__init__.py", line 216, in <lambda>
INTERNALERROR>     firstresult=hook.spec_opts.get('firstresult'),
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/pluggy/callers.py", line 201, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/pluggy/callers.py", line 76, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/pluggy/callers.py", line 175, in _multicall
INTERNALERROR>     next(gen)   # first yield
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/pytest_reportportal/listener.py", line 32, in pytest_runtest_protocol
INTERNALERROR>     self.PyTestService.start_pytest_item(item)
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/pytest_reportportal/service.py", line 194, in start_pytest_item
INTERNALERROR>     part = self._start_stack.pop(0)
INTERNALERROR> IndexError: pop from empty list
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/_pytest/main.py", line 107, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/_pytest/main.py", line 145, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/pluggy/__init__.py", line 617, in __call__
INTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/pluggy/__init__.py", line 222, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/pluggy/__init__.py", line 216, in <lambda>
INTERNALERROR>     firstresult=hook.spec_opts.get('firstresult'),
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/pluggy/callers.py", line 201, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/pluggy/callers.py", line 76, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/pluggy/callers.py", line 180, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "<remote exec>", line 66, in pytest_runtestloop
INTERNALERROR>   File "<remote exec>", line 83, in run_one_test
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/pluggy/__init__.py", line 617, in __call__
INTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/pluggy/__init__.py", line 222, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/pluggy/__init__.py", line 216, in <lambda>
INTERNALERROR>     firstresult=hook.spec_opts.get('firstresult'),
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/pluggy/callers.py", line 201, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/pluggy/callers.py", line 76, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/pluggy/callers.py", line 175, in _multicall
INTERNALERROR>     next(gen)   # first yield
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/pytest_reportportal/listener.py", line 32, in pytest_runtest_protocol
INTERNALERROR>     self.PyTestService.start_pytest_item(item)
INTERNALERROR>   File "/Users/user/git/myProject/qenv/lib/python3.6/site-packages/pytest_reportportal/service.py", line 194, in start_pytest_item
INTERNALERROR>     part = self._start_stack.pop(0)
INTERNALERROR> IndexError: pop from empty list

Expected

No errors

PS

If I run tests sequantely - no errors

pytest tests/test_report_portal.py --reportportal

"requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url:

Tests were running for few hours, and without any disturbances we can see suddenly testsuite was not reaching report portal.

below is the error screenshots.

'''
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/reportportal_client/service_async.py", line 204, in process_item
getattr(self.rp_client, method)(**kwargs)
File "/usr/local/lib/python3.6/site-packages/reportportal_client/service.py", line 187, in finish_test_item
return _get_msg(r)
File "/usr/local/lib/python3.6/site-packages/reportportal_client/service.py", line 22, in _get_msg
return _get_data(response)["msg"]
File "/usr/local/lib/python3.6/site-packages/reportportal_client/service.py", line 39, in _get_data
response.raise_for_status()
File "/usr/local/lib/python3.6/site-packages/requests/models.py", line 935, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: http://10.233.84.37:8082/api/v1/CONCIERG/item/5b16062c3cdea20001d32ec1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.6/site-packages/reportportal_client/service_async.py", line 73, in _monitor
self.handle(record)
File "/usr/local/lib/python3.6/site-packages/reportportal_client/service_async.py", line 54, in handle
handler(record)
File "/usr/local/lib/python3.6/site-packages/reportportal_client/service_async.py", line 208, in process_item
self.terminate(nowait=True)
File "/usr/local/lib/python3.6/site-packages/reportportal_client/service_async.py", line 153, in terminate
raise Error("Service already stopped.")
reportportal_client.errors.Error: Service already stopped.
' ' '

Test Errors not being reported

Test errors are apparently not being reported.
Latest stable release of the client and the master branch tip for the pytest plugin.

Found out about this while running into a too many open files issue.

I'll post more info when I'm at my laptop.

reportportal_client.errors.ResponseError: Error during updating TestItem null

============================================================================ test session starts ============================================================================
platform linux -- Python 3.5.2, pytest-3.1.2, py-1.4.34, pluggy-0.4.0
rootdir: /home/dkorytkin/PycharmProjects/test/tests, inifile: pytest.ini
plugins: reportportal-1.0.0, env-0.6.2, allure-pytest-2.0.0b1
collected 1 items 

tests/test_open_page.py .

========================================================================= 1 passed in 2.27 seconds ==========================================================================
Traceback (most recent call last):
  File "/home/dkorytkin/.local/share/virtualenvs/test-9Ahk-nxU/lib/python3.5/site-packages/reportportal_client/service_async.py", line 204, in process_item
    getattr(self.rp_client, method)(**kwargs)
  File "/home/dkorytkin/.local/share/virtualenvs/test-9Ahk-nxU/lib/python3.5/site-packages/reportportal_client/service.py", line 179, in finish_test_item
    return _get_msg(r)
  File "/home/dkorytkin/.local/share/virtualenvs/test-9Ahk-nxU/lib/python3.5/site-packages/reportportal_client/service.py", line 22, in _get_msg
    return _get_data(response)["msg"]
  File "/home/dkorytkin/.local/share/virtualenvs/test-9Ahk-nxU/lib/python3.5/site-packages/reportportal_client/service.py", line 34, in _get_data
    raise ResponseError(error_messages[0])
reportportal_client.errors.ResponseError: Error during updating TestItem null

Specifying launch tags from command line?

Is there any reason the plugin doesn't support this? I can draw up a pull request real quick but I figured if it wasn't already an option, there must be a reason for it, right?

AttributeError: 'MarkMapping' object has no attribute '_mymarks'

For both Python2 and Python3 for Windows 10.

pytest_reportportal-1.0.1

Example from docs from github.

import pytest
import logging

# Import Report Portal logger and handler to the test module.
from pytest_reportportal import RPLogger, RPLogHandler

# Setting up a logging.
logging.setLoggerClass(RPLogger)
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)

# Create handler for Report Portal.
rp_handler = RPLogHandler()

# Set INFO level for Report Portal handler.
rp_handler.setLevel(logging.INFO)

# Add handler to the logger.
logger.addHandler(rp_handler)


# In this case only INFO messages will be sent to the Report Portal.
def test_one():
    logger.info("Case 1. Step 1")
    x = "this"
    logger.info("x is: %s", x)
    assert 'h' in x

#     Message with an attachment.
    import subprocess
    free_memory = subprocess.check_output("wmic OS get FreePhysicalMemory /Value".split())
    logger.info("Case1. Memory consumption", attachment={"name": "free_memory.txt", "data": free_memory, "mime": "application/octet-stream", }, )

    # This debug message will not be sent to the Report Portal.
    logger.debug("Case1. Debug message")

pytest.ini

[pytest]
rp_uuid = xxxx-xxxx-xxxx
rp_endpoint = https://rp.epam.com
rp_project = ANATOL_KHMIALEUSKI_PERSONAL
rp_launch = AnyLaunchName
rp_launch_tags = 'PyTest'
rp_launch_description = 'Smoke test'
rp_ignore_tags = 'xfail' 'usefixture'
rp_ignore_errors = True

Result

Testing started at 3:24 PM ...
D:\VM\Internal_Tools\PyTest&RP\venv\Scripts\python.exe "C:\Program Files\JetBrains\PyCharm Community Edition 2017.3\helpers\pycharm\_jb_pytest_runner.py" --path test.py -- -v
Launching py.test with arguments -v test.py in D:\VM\Internal_Tools\PyTest&RP

============================= test session starts =============================
platform win32 -- Python 3.6.3, pytest-3.3.0, py-1.5.2, pluggy-0.6.0 -- D:\VM\Internal_Tools\PyTest&RP\venv\Scripts\python.exe
cachedir: .cache
rootdir: D:\VM\Internal_Tools\PyTest&RP, inifile: pytest.ini
plugins: reportportal-1.0.1
collecting ... collected 1 itemINTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "D:\VM\Internal_Tools\PyTest&RP\venv\lib\site-packages\_pytest\main.py", line 103, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "D:\VM\Internal_Tools\PyTest&RP\venv\lib\site-packages\_pytest\main.py", line 141, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "D:\VM\Internal_Tools\PyTest&RP\venv\lib\site-packages\pluggy\__init__.py", line 617, in __call__
INTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "D:\VM\Internal_Tools\PyTest&RP\venv\lib\site-packages\pluggy\__init__.py", line 222, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "D:\VM\Internal_Tools\PyTest&RP\venv\lib\site-packages\pluggy\__init__.py", line 216, in <lambda>
INTERNALERROR>     firstresult=hook.spec_opts.get('firstresult'),
INTERNALERROR>   File "D:\VM\Internal_Tools\PyTest&RP\venv\lib\site-packages\pluggy\callers.py", line 201, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "D:\VM\Internal_Tools\PyTest&RP\venv\lib\site-packages\pluggy\callers.py", line 76, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "D:\VM\Internal_Tools\PyTest&RP\venv\lib\site-packages\pluggy\callers.py", line 180, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "D:\VM\Internal_Tools\PyTest&RP\venv\lib\site-packages\_pytest\main.py", line 164, in pytest_runtestloop
INTERNALERROR>     item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR>   File "D:\VM\Internal_Tools\PyTest&RP\venv\lib\site-packages\pluggy\__init__.py", line 617, in __call__
INTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "D:\VM\Internal_Tools\PyTest&RP\venv\lib\site-packages\pluggy\__init__.py", line 222, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "D:\VM\Internal_Tools\PyTest&RP\venv\lib\site-packages\pluggy\__init__.py", line 216, in <lambda>
INTERNALERROR>     firstresult=hook.spec_opts.get('firstresult'),
INTERNALERROR>   File "D:\VM\Internal_Tools\PyTest&RP\venv\lib\site-packages\pluggy\callers.py", line 201, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "D:\VM\Internal_Tools\PyTest&RP\venv\lib\site-packages\pluggy\callers.py", line 76, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "D:\VM\Internal_Tools\PyTest&RP\venv\lib\site-packages\pluggy\callers.py", line 175, in _multicall
INTERNALERROR>     next(gen)   # first yield
INTERNALERROR>   File "D:\VM\Internal_Tools\PyTest&RP\venv\lib\site-packages\pytest_reportportal\listener.py", line 19, in pytest_runtest_protocol
INTERNALERROR>     PyTestService.start_pytest_item(item)
INTERNALERROR>   File "D:\VM\Internal_Tools\PyTest&RP\venv\lib\site-packages\pytest_reportportal\service.py", line 103, in start_pytest_item
INTERNALERROR>     'tags': self._get_tags(test_item),
INTERNALERROR>   File "D:\VM\Internal_Tools\PyTest&RP\venv\lib\site-packages\pytest_reportportal\service.py", line 118, in _get_tags
INTERNALERROR>     marks = mark_plugin.MarkMapping(keywords)._mymarks
INTERNALERROR> AttributeError: 'MarkMapping' object has no attribute '_mymarks'

======================== no tests ran in 0.03 seconds =========================

Process finished with exit code 0
Empty test suite.

Unable to see any launch results for the project

I have followed the instructions to configure the test framework, but still unable to see any launch results in the portal. Attempted to use IP and domain name, put ini file in different places, with no luck.

The instance with portal is pingable and POST/GET requests are successful from the terminal. Screenshot with the automation project structure has been attached.
Please suggest how to solve the issue.
Python 3.7, pytest package 4.0.0

screen_1

rp_logger fixture from readme raises AttributeError

My pytest.ini file is configured with the following:

[pytest]
addopts = --no-print-logs --html=report.html --self-contained-html
rp.endpoint = http://localhost:8080
rp.uuid = 23646431-1a4b-4bdd-8ffd-c765d55358e7
rp.launch = default_TEST_EXAMPLE
rp.project = default_personal
rp.enable = true
rp.description = My awesome launch
rp.tags = TAG1;TAG2
rp.convertimage = true
rp.mode = DEFAULT
rp.skipped.issue = true
rp.batch.size.logs = 20

My test is:

import pytest

from modules.configuration import Thinstances
from modules.custom_exceptions import InvalidSystemError


def test_is_valid_system(rp_logger):
    """Check that a valid value returns True, and an invalid value returns False."""
    rp_logger.info("Case1. Step1")
    assert Thinstances.is_valid_system('onedevqa') == 'onedevqa'
    assert Thinstances.is_valid_system('ONEDEVQA') == 'onedevqa'
    assert Thinstances.is_valid_system('OneDevStaging') == 'onedevstaging'
    assert Thinstances.is_valid_system('onedev12') == 'onedev12'

Conftest:

"""Functions designed for use by our entire pytest framework."""
import pytest


@pytest.fixture(scope="session")
def rp_logger(request):
    import logging
    # Import Report Portal logger and handler to the test module.
    from pytest_reportportal import RPLogger, RPLogHandler
    # Setting up a logging.
    logging.setLoggerClass(RPLogger)
    logger = logging.getLogger(__name__)
    logger.setLevel(logging.DEBUG)
    # Create handler for Report Portal.
    rp_handler = RPLogHandler(request.node.config.py_test_service)
    # Set INFO level for Report Portal handler.
    rp_handler.setLevesl(logging.INFO)
    logger.addHandler(rp_handler)
    return logger

And error raised is:

request = <SubRequest 'rp_logger' for <Function 'test_is_valid_system'>>

    @pytest.fixture(scope="session")
    def rp_logger(request):
        import logging
        # Import Report Portal logger and handler to the test module.
        from pytest_reportportal import RPLogger, RPLogHandler
        # Setting up a logging.
        logging.setLoggerClass(RPLogger)
        logger = logging.getLogger(__name__)
        logger.setLevel(logging.DEBUG)
        # Create handler for Report Portal.
>       rp_handler = RPLogHandler(request.node.config.py_test_service)
E       AttributeError: 'Config' object has no attribute 'py_test_service'

Seems a little related to issue #57. I tried the If block mentioned in the comments but nothing is logged in reportportal. Not sure what else to try from here.

AttributeError: 'Config' object has no attribute 'py_test_service' coming while deactivate pytest_reportportal plugin

I am getting following error when i would like to temporary disable integrations with Report Portal just deactivate pytest_reportportal plugin with command: py.test -p no:pytest_reportportal ./tests

I am currently running this with Python 3.6 and the latest pytest.

Trace:
request = <SubRequest 'rp_logger' for <Function 'test_one'>>
    @pytest.fixture(scope="function")
    def rp_logger(request):
        import logging
        # Import Report Portal logger and handler to the test module.
        from pytest_reportportal import RPLogger, RPLogHandler
        # Setting up a logging.
        logging.setLoggerClass(RPLogger)
        logger = logging.getLogger(__name__)
        logger.setLevel(logging.DEBUG)
        # Create handler for Report Portal.
>       rp_handler = RPLogHandler(request.node.config.py_test_service)
E       AttributeError: 'Config' object has no attribute 'py_test_service'

Separate all test by modules in report portal

Enhancement
Now result of each test in suite is writed directly to one launch in report portal (All > Pytest Launch > All tests). It would be good to add some separation by modules and fixtures. Like this: All > Pytest Launch > tests/path.py > test_name (and think about > fixtures of test and test)

reportportal_client.errors.ResponseError: 40023

platform linux -- Python 3.5.2, pytest-3.1.2, py-1.4.34, pluggy-0.4.0
rootdir: /home/dkorytkin/PycharmProjects/test/tests, inifile: pytest.ini
plugins: reportportal-1.0.0, env-0.6.2, allure-pytest-2.0.0b1
collected 1 items 

tests/test_open_page.py .

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/reportportal_client/service_async.py", line 204, in process_item
    getattr(self.rp_client, method)(**kwargs)
  File "/usr/local/lib/python3.5/dist-packages/reportportal_client/service.py", line 140, in finish_launch
    return _get_msg(r)
  File "/usr/local/lib/python3.5/dist-packages/reportportal_client/service.py", line 22, in _get_msg
    return _get_data(response)["msg"]
  File "/usr/local/lib/python3.5/dist-packages/reportportal_client/service.py", line 34, in _get_data
    raise ResponseError(error_messages[0])
reportportal_client.errors.ResponseError: 40023: Finish launch is not allowed. Launch '595100c1b9d82100058c4dfe' has items '[595100c1b9d82100058c4e00]' with 'IN_PROGRESS' status```

SSL Errors are hidden

While working on #90 it took me awhile to figure out the underlying error (SSL not being verified by requests) as all I saw in the logs was 'Launch not found').

It would be useful if client-Python errors were exposed somehow to the user/pytest.

service stopped when running second time and also AttributeError: 'NoneType' object has no attribute 'post_log'

platform linux2 -- Python 2.7.14, pytest-3.4.2, py-1.5.2, pluggy-0.6.0
metadata: {'Platform': 'Linux-4.15.6-300.fc27.x86_64-x86_64-with-fedora-27-Twenty_Seven', 'JAVA_HOME': '/usr/java/default', 'WORKSPACE': '/home/talayan/git', 'Plugins': {'jira': '0.3.6', 'art': '0.0.0', 'ordering': '0.5', 'marker-bugzilla': '0.7', 'reportportal': '1.0.1', 'flaky': '3.3.0', 'html': '1.16.0', 'forked': '0.2', 'metadata': '1.5.1'}, 'Python': '2.7.14', 'Packages': {'py': '1.5.2', 'pytest': '3.4.2', 'pluggy': '0.6.0'}}
rootdir: /home/talayan/git/rhevm-art/art/tests/rhevmtests/acceptance/sanity, inifile: /home/talayan/git/rhevm-art/pytest_customization/pytest.cfg
plugins: art-0.0.0, reportportal-1.0.1, ordering-0.5, marker-bugzilla-0.7, jira-0.3.6, forked-0.2, metadata-1.5.1, html-1.16.0, flaky-3.3.0
collected 1 item                                                                                                                                                                             

art/tests/rhevmtests/acceptance/sanity/sanity_test.py Exception in thread Thread-13:
Traceback (most recent call last):
  File "/usr/lib64/python2.7/threading.py", line 804, in __bootstrap_inner
    self.run()
  File "/usr/lib64/python2.7/threading.py", line 757, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/home/talayan/git/rhevm-art/.art/lib/python2.7/site-packages/reportportal_client/service_async.py", line 73, in _monitor
    self.handle(record)
  File "/home/talayan/git/rhevm-art/.art/lib/python2.7/site-packages/reportportal_client/service_async.py", line 54, in handle
    handler(record)
  File "/home/talayan/git/rhevm-art/.art/lib/python2.7/site-packages/reportportal_client/service_async.py", line 208, in process_item
    self.terminate(nowait=True)
  File "/home/talayan/git/rhevm-art/.art/lib/python2.7/site-packages/reportportal_client/service_async.py", line 153, in terminate
    raise Error("Service already stopped.")
Error: Service already stopped.

Traceback (most recent call last):
  File "/home/talayan/git/rhevm-art/.art/lib/python2.7/site-packages/reportportal_client/service_async.py", line 204, in process_item
    getattr(self.rp_client, method)(**kwargs)
  File "/home/talayan/git/rhevm-art/.art/lib/python2.7/site-packages/reportportal_client/service.py", line 170, in start_test_item
    r = self.session.post(url=url, json=data)
  File "/home/talayan/git/rhevm-art/.art/lib/python2.7/site-packages/requests/sessions.py", line 555, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/home/talayan/git/rhevm-art/.art/lib/python2.7/site-packages/requests/sessions.py", line 508, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/talayan/git/rhevm-art/.art/lib/python2.7/site-packages/requests/sessions.py", line 618, in send
    r = adapter.send(request, **kwargs)
  File "/home/talayan/git/rhevm-art/.art/lib/python2.7/site-packages/requests/adapters.py", line 440, in send
    timeout=timeout
  File "/home/talayan/git/rhevm-art/.art/lib/python2.7/site-packages/urllib3/connectionpool.py", line 601, in urlopen
    chunked=chunked)
  File "/home/talayan/git/rhevm-art/.art/lib/python2.7/site-packages/urllib3/connectionpool.py", line 396, in _make_request
    httplib_response.length)
  File "/usr/lib64/python2.7/logging/__init__.py", line 1155, in debug
    self._log(DEBUG, msg, args, **kwargs)
  File "/home/talayan/git/rhevm-art/.art/lib/python2.7/site-packages/pytest_reportportal/rp_logging.py", line 113, in _log
    return original_func(self, *args, **kwargs)
  File "/usr/lib64/python2.7/logging/__init__.py", line 1286, in _log
    self.handle(record)
  File "/usr/lib64/python2.7/logging/__init__.py", line 1296, in handle
    self.callHandlers(record)
  File "/usr/lib64/python2.7/logging/__init__.py", line 1336, in callHandlers
    hdlr.handle(record)
  File "/usr/lib64/python2.7/logging/__init__.py", line 759, in handle
    self.emit(record)
  File "/home/talayan/git/rhevm-art/.art/lib/python2.7/site-packages/pytest_reportportal/rp_logging.py", line 92, in emit
    return self.py_test_service.post_log(
AttributeError: 'NoneType' object has no attribute 'post_log'

Incorrect value in save log request caused by @pytest.mark.xfail(run=False)

example of test:

    @pytest.mark.xfail(run=False)
    def test_mark_xfail(self):
        assert True is False

run:

pytest
======================================================================================= test session starts ========================================================================================
platform darwin -- Python 3.6.1, pytest-3.1.2, py-1.4.34, pluggy-0.4.0
rootdir: /Users/x/autotests, inifile: pytest.ini
plugins: xdist-1.14, timeout-1.2.0, reportportal-1.0.0, allure-adaptor-1.7.7
collected 2502 items 

tests.py F.....xTraceback (most recent call last):
  File "/Users/x/autotests/.env/lib/python3.6/site-packages/reportportal_client/service_async.py", line 203, in process_item
    self._post_log_batch()
  File "/Users/x/autotests/.env/lib/python3.6/site-packages/reportportal_client/service_async.py", line 173, in _post_log_batch
    self.rp_client.log_batch(self.log_batch)
  File "/Users/x/autotests/.env/lib/python3.6/site-packages/reportportal_client/service.py", line 245, in log_batch
    return _get_data(r)
  File "/Users/x/autotests/.env/lib/python3.6/site-packages/reportportal_client/service.py", line 34, in _get_data
    raise ResponseError(error_messages[0])
reportportal_client.errors.ResponseError: ReportPortalException: Incorrect Request. [Incorrect value in save log request 'null' in field 'testItemId'.]


INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/main.py", line 105, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/main.py", line 141, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 745, in __call__
INTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 339, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 334, in <lambda>
INTERNALERROR>     _MultiCall(methods, kwargs, hook.spec_opts).execute()
INTERNALERROR>   File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 614, in execute
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/main.py", line 164, in pytest_runtestloop
INTERNALERROR>     item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR>   File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 745, in __call__
INTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 339, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 334, in <lambda>
INTERNALERROR>     _MultiCall(methods, kwargs, hook.spec_opts).execute()
INTERNALERROR>   File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 613, in execute
INTERNALERROR>     return _wrapped_call(hook_impl.function(*args), self.execute)
INTERNALERROR>   File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 254, in _wrapped_call
INTERNALERROR>     return call_outcome.get_result()
INTERNALERROR>   File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 279, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 265, in __init__
INTERNALERROR>     self.result = func()
INTERNALERROR>   File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 613, in execute
INTERNALERROR>     return _wrapped_call(hook_impl.function(*args), self.execute)
INTERNALERROR>   File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 254, in _wrapped_call
INTERNALERROR>     return call_outcome.get_result()
INTERNALERROR>   File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 279, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 265, in __init__
INTERNALERROR>     self.result = func()
INTERNALERROR>   File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 613, in execute
INTERNALERROR>     return _wrapped_call(hook_impl.function(*args), self.execute)
INTERNALERROR>   File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 254, in _wrapped_call
INTERNALERROR>     return call_outcome.get_result()
INTERNALERROR>   File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 279, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 265, in __init__
INTERNALERROR>     self.result = func()
INTERNALERROR>   File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 613, in execute
INTERNALERROR>     return _wrapped_call(hook_impl.function(*args), self.execute)
INTERNALERROR>   File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 254, in _wrapped_call
INTERNALERROR>     return call_outcome.get_result()
INTERNALERROR>   File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 279, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 265, in __init__
INTERNALERROR>     self.result = func()
INTERNALERROR>   File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 614, in execute
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/runner.py", line 60, in pytest_runtest_protocol
INTERNALERROR>     runtestprotocol(item, nextitem=nextitem)
INTERNALERROR>   File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/runner.py", line 67, in runtestprotocol
INTERNALERROR>     rep = call_and_report(item, "setup", log)
INTERNALERROR>   File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/runner.py", line 129, in call_and_report
INTERNALERROR>     report = hook.pytest_runtest_makereport(item=item, call=call)
INTERNALERROR>   File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 745, in __call__
INTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 339, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 334, in <lambda>
INTERNALERROR>     _MultiCall(methods, kwargs, hook.spec_opts).execute()
INTERNALERROR>   File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 613, in execute
INTERNALERROR>     return _wrapped_call(hook_impl.function(*args), self.execute)
INTERNALERROR>   File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 250, in _wrapped_call
INTERNALERROR>     wrap_controller.send(call_outcome)
INTERNALERROR>   File "/Users/x/autotests/tests/conftest.py", line 186, in pytest_runtest_makereport
INTERNALERROR>     rep = outcome.get_result()
INTERNALERROR>   File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 279, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 265, in __init__
INTERNALERROR>     self.result = func()
INTERNALERROR>   File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 613, in execute
INTERNALERROR>     return _wrapped_call(hook_impl.function(*args), self.execute)
INTERNALERROR>   File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 250, in _wrapped_call
INTERNALERROR>     wrap_controller.send(call_outcome)
INTERNALERROR>   File "/Users/x/autotests/.env/lib/python3.6/site-packages/pytest_reportportal/plugin.py", line 28, in pytest_runtest_makereport
INTERNALERROR>     loglevel='ERROR',
INTERNALERROR>   File "/Users/x/autotests/.env/lib/python3.6/site-packages/pytest_reportportal/service.py", line 140, in post_log
INTERNALERROR>     self.RP.log(**sl_rq)
INTERNALERROR>   File "/Users/x/autotests/.env/lib/python3.6/site-packages/reportportal_client/service_async.py", line 274, in log
INTERNALERROR>     self.queue.put_nowait(("log", args))
INTERNALERROR> AttributeError: 'NoneType' object has no attribute 'put_nowait'
Traceback (most recent call last):
  File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/config.py", line 58, in main
    return config.hook.pytest_cmdline_main(config=config)
  File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 745, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 339, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 334, in <lambda>
    _MultiCall(methods, kwargs, hook.spec_opts).execute()
  File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 614, in execute
    res = hook_impl.function(*args)
  File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/main.py", line 134, in pytest_cmdline_main
    return wrap_session(config, _main)
  File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/main.py", line 128, in wrap_session
    exitstatus=session.exitstatus)
  File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 745, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 339, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 334, in <lambda>
    _MultiCall(methods, kwargs, hook.spec_opts).execute()
  File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 613, in execute
    return _wrapped_call(hook_impl.function(*args), self.execute)
  File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 250, in _wrapped_call
    wrap_controller.send(call_outcome)
  File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/terminal.py", line 386, in pytest_sessionfinish
    outcome.get_result()
  File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 279, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 265, in __init__
    self.result = func()
  File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 614, in execute
    res = hook_impl.function(*args)
  File "/Users/x/autotests/.env/lib/python3.6/site-packages/pytest_reportportal/plugin.py", line 77, in pytest_sessionfinish
    PyTestService.finish_launch(status="RP_Launch")
  File "/Users/x/autotests/.env/lib/python3.6/site-packages/pytest_reportportal/service.py", line 126, in finish_launch
    self.RP.finish_launch(**fl_rq)
  File "/Users/x/autotests/.env/lib/python3.6/site-packages/reportportal_client/service_async.py", line 233, in finish_launch
    self.queue.put_nowait(("finish_launch", args))
AttributeError: 'NoneType' object has no attribute 'put_nowait'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/x/autotests/.env/bin/pytest", line 11, in <module>
    sys.exit(main())
  File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/config.py", line 60, in main
    config._ensure_unconfigure()
  File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/config.py", line 917, in _ensure_unconfigure
    self.hook.pytest_unconfigure(config=self)
  File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 745, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 339, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 334, in <lambda>
    _MultiCall(methods, kwargs, hook.spec_opts).execute()
  File "/Users/x/autotests/.env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 614, in execute
    res = hook_impl.function(*args)
  File "/Users/x/autotests/.env/lib/python3.6/site-packages/pytest_reportportal/plugin.py", line 92, in pytest_unconfigure
    PyTestService.terminate_service()
  File "/Users/x/autotests/.env/lib/python3.6/site-packages/pytest_reportportal/service.py", line 54, in terminate_service
    self.RP.terminate()
  File "/Users/x/autotests/.env/lib/python3.6/site-packages/reportportal_client/service_async.py", line 153, in terminate
    raise Error("Service already stopped.")
reportportal_client.errors.Error: Service already stopped.

In reportportal: 2 launches that will not stop

Not-started service termination for wrong uuid.

Need to check with more options.

How to reproduce:

  1. Create pytest.ini file and specify invalid rp_uuid parameter and rp_ignore_errors = True.
  2. Copy paste example from readme file to test_sample.py
  3. Run tests with command: pytest test_sample.py

Actual result for launch with all passed tests:
Traceback about service terminating is printed out but should not.

$ pytest test_sample.py 
============================================================ test session starts =============================================================
platform linux2 -- Python 2.7.12, pytest-3.1.1, py-1.4.33, pluggy-0.4.0
rootdir: /home/ykrasouski/ReportPortal, inifile: pytest.ini
plugins: reportportal-1.0.0
collected 1 items 

test_sample.py .

========================================================== 1 passed in 0.01 seconds ==========================================================
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/home/ykrasouski/ReportPortal/client-python/reportportal_client/service_async.py", line 73, in _monitor
    self.handle(record)
  File "/home/ykrasouski/ReportPortal/client-python/reportportal_client/service_async.py", line 54, in handle
    handler(record)
  File "/home/ykrasouski/ReportPortal/client-python/reportportal_client/service_async.py", line 208, in process_item
    self.terminate(nowait=True)
  File "/home/ykrasouski/ReportPortal/client-python/reportportal_client/service_async.py", line 153, in terminate
    raise Error("Service already stopped.")
Error: Service already stopped.

Actual result for launch with failed tests:
In some cases output mixed up due to thread like bellow:

$ pytest test_sample.py 
============================================================ test session starts =============================================================
platform linux2 -- Python 2.7.12, pytest-3.1.1, py-1.4.33, pluggy-0.4.0
rootdir: /home/ykrasouski/ReportPortal, inifile: pytest.ini
plugins: reportportal-1.0.0
collected 1 items 

test_sample.py FTraceback (most recent call last):
  File "/home/ykrasouski/ReportPortal/client-python/reportportal_client/service_async.py", line 204, in process_item
    getattr(self.rp_client, method)(**kwargs)
  File "/home/ykrasouski/ReportPortal/client-python/reportportal_client/service.py", line 126, in start_launch
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/home/ykrasouski/ReportPortal/client-python/reportportal_client/service_async.py", line 73, in _monitor
    self.handle(record)
  File "/home/ykrasouski/ReportPortal/client-python/reportportal_client/service_async.py", line 54, in handle
    handler(record)
  File "/home/ykrasouski/ReportPortal/client-python/reportportal_client/service_async.py", line 208, in process_item
    self.terminate(nowait=True)
  File "/home/ykrasouski/ReportPortal/client-python/reportportal_client/service_async.py", line 153, in terminate
    raise Error("Service already stopped.")
Error: Service already stopped.

    self.launch_id = _get_id(r)
  File "/home/ykrasouski/ReportPortal/client-python/reportportal_client/service.py", line 14, in _get_id
    return _get_data(response)["id"]
  File "/home/ykrasouski/ReportPortal/client-python/reportportal_client/service.py", line 39, in _get_data
    response.raise_for_status()
  File "/home/ykrasouski/.virtualenvs/rp/local/lib/python2.7/site-packages/requests/models.py", line 929, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
HTTPError: 401 Client Error:  for url: https://rp/api/v1/project/launch


================================================================== FAILURES ==================================================================
__________________________________________________________________ test_one __________________________________________________________________

    def test_one():
        logger.info("Case1. Step1")
        x = "this"
        logger.info("x is: %s", x)
>       assert 'x' in x
E       AssertionError: assert 'x' in 'this'

test_sample.py:20: AssertionError
------------------------------------------------------------ Captured stderr call ------------------------------------------------------------
INFO:test_sample:Case1. Step1
INFO:test_sample:x is: this
========================================================== 1 failed in 0.03 seconds ==========================================================

pytest-reportportal hangs approx 1 out of 3 launches

I am experiencing flakey behaviour with pytest-reportportal. This pytest plugin is active when running tests in Jenkins. The test results are then pushed to ReportPortal. Both systems run in the same set of machines on the company AWS account.

The unit test suite for one of our projects contains 2540 tests at the time of writing. Since we also have a precommit trigger on this project, I know for sure that all unit tests succeed.

When pushing the test results from Jenkins to RP, 1 out of 3 executions (on average) seem to hang. I have to kill the ongoing Jenkins run and then Force finish the launch on RP. This is not maintainable.

I would like to add more info, but the Jenkins console just sits there. The last line being reported was pytest saying that all tests ran correctly:

========================= 2540 passed in 31.49 seconds =========================

upload image to report

I try to upload image to report
so the example in the agent-python doc is about text file and it works well

import subprocess
    free_memory = subprocess.check_output("free -h".split())
    rp_logger.info(
        "Case1. Memory consumption",
        attachment={
            "name": "free_memory.txt",
            "data": free_memory,
            "mime": "application/octet-stream",
        },
    )

but if you want to upload image there is a problem
in the data key do you can't pass the path to the file because the path pass as a string to report portal, if you change the mime to image/png do you get 5000 code error (the data will be upload but the report portal can't load the file)

after investigation the way that it works for me is to load the file as a file, like this

with open(screenshot_file_path, "rb") as image_file:
        screenshot_file_path = image_file.read()
rp_logger.info("Some Text Here",
                       attachment={"name": "test_name_screenshot.png",
                                             "data": screenshot_file_path,
                                             "mime": "image/png"})

it will be nice to document this

Logs are doubled exponentially after runnig more than one test

I run tests with logging, and after that log message in Report Portal is duplicated
In PyCharm console everything is OK

First test 1 log in code = 1 log message
Second test 1 log in code = 2 log message
Third test 1 log in code = 3 log message

conftest.py

import pytest

@pytest.fixture(scope="function")
def rp_logger(request):
    import logging
    # Import Report Portal logger and handler to the test module.
    from pytest_reportportal import RPLogger, RPLogHandler
    # Setting up a logging.
    logging.setLoggerClass(RPLogger)
    logger = logging.getLogger(__name__)
    logger.setLevel(logging.DEBUG)
    # Create handler for Report Portal.
    rp_handler = RPLogHandler(request.node.config.py_test_service)
    # Set INFO level for Report Portal handler.
    rp_handler.setLevel(logging.INFO)
    # Add handler to the logger.
    logger.addHandler(rp_handler)
    return logger

test_web.py

from selenium import webdriver

def test_login(rp_logger):
    driver = webdriver.Chrome(executable_path='chromedriver.exe')
    rp_logger.info('------------11--------------')
    driver.implicitly_wait(10)
    rp_logger.info('------------12--------------')
    driver.get('https://facebook.com')
    rp_logger.info('------------13--------------')
    driver.quit()


def test_login_2(rp_logger):
    driver = webdriver.Chrome(executable_path='chromedriver.exe')
    rp_logger.info('------------21--------------')
    driver.implicitly_wait(10)
    rp_logger.info('------------22--------------')
    driver.get('https://facebook.com')
    rp_logger.info('------------23--------------')
    driver.quit()

def test_login_3(rp_logger):
    driver = webdriver.Chrome(executable_path='chromedriver.exe')
    rp_logger.info('------------31--------------')
    driver.implicitly_wait(10)
    rp_logger.info('------------32--------------')
    driver.get('https://facebook.com')
    rp_logger.info('------------33--------------')
    driver.quit()

Console Log

============================= test session starts =============================
platform win32 -- Python 3.6.3, pytest-3.2.5, py-1.5.3, pluggy-0.4.0
rootdir: C:\Users\Aleksey\PycharmProjects\web_rp, inifile: pytest.ini
plugins: reportportal-1.0.3, allure-pytest-2.2.3b1
collected 3 items
test_web.py .INFO:conftest:------------11--------------
INFO:conftest:------------12--------------
INFO:conftest:------------13--------------
.INFO:conftest:------------21--------------
INFO:conftest:------------22--------------
INFO:conftest:------------23--------------
.INFO:conftest:------------31--------------
INFO:conftest:------------32--------------
INFO:conftest:------------33--------------

Log Messgae on Report Portal
chrome_2018-06-18_15-10-08

chrome_2018-06-18_15-09-21

chrome_2018-06-18_14-54-10

Deadlock when using asyncio

I noticed this rare deadlock traced back to the reportportal plugin. This only occurs on python3 when using asyncio.

It seems that the queue.Empty exception is not caught right away and that causes more logs to be generated by the asyncio framework.

Traceback (most recent call first):
  <built-in method __enter__ of _thread.lock object at remote 0x7f7e3e147878>
  File "/usr/lib/python3.6/threading.py", line 240, in __enter__
    return self._lock.__enter__()
  File "/usr/lib/python3.6/queue.py", line 158, in get
    with self.not_empty:
  File "lib/python3.6/site-packages/pytest_reportportal/service.py", line 287, in _stop_if_necessary
    exc, msg, tb = self._errors.get(False)
  File "lib/python3.6/site-packages/pytest_reportportal/service.py", line 268, in post_log
    self._stop_if_necessary()
  File "lib/python3.6/site-packages/pytest_reportportal/rp_logging.py", line 101, in emit
    attachment=record.__dict__.get('attachment', None),
  File "/usr/lib/python3.6/logging/__init__.py", line 865, in handle
    self.emit(record)
  File "/usr/lib/python3.6/logging/__init__.py", line 1516, in callHandlers
    hdlr.handle(record)
  File "/usr/lib/python3.6/logging/__init__.py", line 1454, in handle
    self.callHandlers(record)
  File "/usr/lib/python3.6/logging/__init__.py", line 1444, in _log
    self.handle(record)
  File "/usr/lib/python3.6/logging/__init__.py", line 1337, in error
    self._log(ERROR, msg, args, **kwargs)
  File "/usr/lib/python3.6/asyncio/base_events.py", line 1274, in default_exception_handler
    logger.error('\n'.join(log_lines), exc_info=exc_info)
  File "/usr/lib/python3.6/asyncio/base_events.py", line 1299, in call_exception_handler
    self.default_exception_handler(context)
  File "/usr/lib/python3.6/queue.py", line 161, in get
    raise Empty
  File "lib/python3.6/site-packages/pytest_reportportal/service.py", line 287, in _stop_if_necessary
    exc, msg, tb = self._errors.get(False)
  File "lib/python3.6/site-packages/pytest_reportportal/service.py", line 268, in post_log
    self._stop_if_necessary()
  File "lib/python3.6/site-packages/pytest_reportportal/rp_logging.py", line 101, in emit
    attachment=record.__dict__.get('attachment', None),
  File "/usr/lib/python3.6/logging/__init__.py", line 865, in handle
    self.emit(record)
  File "/usr/lib/python3.6/logging/__init__.py", line 1516, in callHandlers
    hdlr.handle(record)
  File "/usr/lib/python3.6/logging/__init__.py", line 1454, in handle
    self.callHandlers(record)
  File "/usr/lib/python3.6/logging/__init__.py", line 1444, in _log
    self.handle(record)
  File "/usr/lib/python3.6/logging/__init__.py", line 1296, in debug
    self._log(DEBUG, msg, args, **kwargs)
  File "lib/python3.6/site-packages/hpack/hpack.py", line 62, in encode_integer
    log.debug("Encoding %d with %d bits", integer, prefix_bits)
  File "lib/python3.6/site-packages/hpack/hpack.py", line 313, in _encode_indexed
    field = encode_integer(index, 7)
  File "lib/python3.6/site-packages/hpack/hpack.py", line 294, in add
    encoded = self._encode_indexed(index)
  File "lib/python3.6/site-packages/hpack/hpack.py", line 257, in encode
    header_block.append(self.add(header, sensitive, huffman))
...

ReportPortalServiceAsync class missing a few attributs - errors return

The first issue

In the service.py file class initial with verify_ssl argument

self.RP = ReportPortalServiceAsync(
                endpoint=endpoint,
                project=project,
                token=uuid,
                error_handler=self.async_error_handler,
                log_batch_size=log_batch_size,
                verify_ssl=verify_ssl
            )

there is no verify_ssl parameter for ReportPortalServiceAsync class
as you can see

class ReportPortalServiceAsync(object):
    """Wrapper around service class to transparently provide async operations
    to agents.
    """

    def __init__(self, endpoint, project, token, api_base="api/v1",
                 error_handler=None, log_batch_size=20):

this problem create this error


pyest project-tests\tests\suit_basic_tests.py --reportportal
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "c:\users\myuser\appdata\local\programs\python\python36-32\lib\site-packages\_pytest\main.py", line 207, in wrap_session
INTERNALERROR>     config.hook.pytest_sessionstart(session=session)
INTERNALERROR>   File "c:\users\myuser\appdata\local\programs\python\python36-32\lib\site-packages\pluggy\hooks.py", line 289, in __call__
INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR>   File "c:\users\myuser\appdata\local\programs\python\python36-32\lib\site-packages\pluggy\manager.py", line 68, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "c:\users\myuser\appdata\local\programs\python\python36-32\lib\site-packages\pluggy\manager.py", line 62, in <lambda>
INTERNALERROR>     firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
INTERNALERROR>   File "c:\users\myuser\appdata\local\programs\python\python36-32\lib\site-packages\pluggy\callers.py", line 208, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "c:\users\myuser\appdata\local\programs\python\python36-32\lib\site-packages\pluggy\callers.py", line 80, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "c:\users\myuser\appdata\local\programs\python\python36-32\lib\site-packages\pluggy\callers.py", line 187, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "c:\users\myuser\appdata\local\programs\python\python36-32\lib\site-packages\pytest_reportportal\plugin.py", line 57, in pytest_sessionstart
INTERNALERROR>     verify_ssl=session.config.getini('rp_verify_ssl')
INTERNALERROR>   File "c:\users\myuser\appdata\local\programs\python\python36-32\lib\site-packages\pytest_reportportal\service.py", line 97, in init_service
INTERNALERROR>     verify_ssl=verify_ssl
INTERNALERROR> TypeError: __init__() got an unexpected keyword argument 'verify_ssl'

The second issue

the same place in service.py
after ReportPortalServiceAsync class initial the code try to call to get_project_settings function
it look like this

self.RP = ReportPortalServiceAsync(
                endpoint=endpoint,
                project=project,
                token=uuid,
                error_handler=self.async_error_handler,
                log_batch_size=log_batch_size,
                # verify_ssl=verify_ssl
            )
self.project_settiings = self.RP.rp_client.get_project_settings() if self.RP else None
self.issue_types = self.get_issue_types()

this method doesn't exist in the ReportPortalServiceAsync class
while running this error return

INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "c:\users\myuser\appdata\local\programs\python\python36-32\lib\site-packages\_pytest\main.py", line 207, in wrap_session
INTERNALERROR>     config.hook.pytest_sessionstart(session=session)
INTERNALERROR>   File "c:\users\myuser\appdata\local\programs\python\python36-32\lib\site-packages\pluggy\hooks.py", line 289, in __call__
INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR>   File "c:\users\myuser\appdata\local\programs\python\python36-32\lib\site-packages\pluggy\manager.py", line 68, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "c:\users\myuser\appdata\local\programs\python\python36-32\lib\site-packages\pluggy\manager.py", line 62, in <lambda>
INTERNALERROR>     firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
INTERNALERROR>   File "c:\users\myuser\appdata\local\programs\python\python36-32\lib\site-packages\pluggy\callers.py", line 208, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "c:\users\myuser\appdata\local\programs\python\python36-32\lib\site-packages\pluggy\callers.py", line 80, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "c:\users\myuser\appdata\local\programs\python\python36-32\lib\site-packages\pluggy\callers.py", line 187, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "c:\users\myuser\appdata\local\programs\python\python36-32\lib\site-packages\pytest_reportportal\plugin.py", line 57, in pytest_sessionstart
INTERNALERROR>     verify_ssl=session.config.getini('rp_verify_ssl')
INTERNALERROR>   File "c:\users\myuser\appdata\local\programs\python\python36-32\lib\site-packages\pytest_reportportal\service.py", line 100, in init_service
INTERNALERROR>     self.project_settiings = self.RP.rp_client.get_project_settings() if self.RP else None
INTERNALERROR> AttributeError: 'ReportPortalService' object has no attribute 'get_project_settings'

py.test --reportportal ./tests/test_flight.py fails, So does pytest --tests-per-worker 2 --reportportal

Below are the failure logs, Creates a launch in the report portal but tests are not executed and launch does not end:

C:\Users\sb\PycharmProjects\pyTest1>py.test --reportportal ./tests/test_flight.py
============================= test session starts =============================
platform win32 -- Python 3.7.0, pytest-3.8.0, py-1.6.0, pluggy-0.7.1
rootdir: C:\Users\sb\PycharmProjects\pyTest1, inifile: pytest.ini
plugins: xdist-1.23.0, rerunfailures-4.1, reportportal-1.0.4, parallel-0.0.3, metadata-1.7.0, html-1.19.0, forked-0.2, concurrent-0.1.2, allure-pytest-2.5.1
collecting 0 items
DevTools listening on ws://127.0.0.1:12593/devtools/browser/fd6154c2-e371-4f69-a097-503b9795f29f
collected 1 item
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "c:\users\sb\appdata\local\programs\python\python37-32\lib\site-packages_pytest\main.py", line 178, in wrap_session
INTERNALERROR> session.exitstatus = doit(config, session) or 0
INTERNALERROR> File "c:\users\sb\appdata\local\programs\python\python37-32\lib\site-packages_pytest\main.py", line 215, in _main
INTERNALERROR> config.hook.pytest_runtestloop(session=session)
INTERNALERROR> File "c:\users\sb\appdata\local\programs\python\python37-32\lib\site-packages\pluggy\hooks.py", line 258, in call
INTERNALERROR> return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR> File "c:\users\sb\appdata\local\programs\python\python37-32\lib\site-packages\pluggy\manager.py", line 67, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File "c:\users\sb\appdata\local\programs\python\python37-32\lib\site-packages\pluggy\manager.py", line 61, in
INTERNALERROR> firstresult=hook.spec_opts.get('firstresult'),
INTERNALERROR> File "c:\users\sb\appdata\local\programs\python\python37-32\lib\site-packages\pluggy\callers.py", line 201, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File "c:\users\sb\appdata\local\programs\python\python37-32\lib\site-packages\pluggy\callers.py", line 76, in get_result
INTERNALERROR> raise ex[1].with_traceback(ex[2])
INTERNALERROR> File "c:\users\sb\appdata\local\programs\python\python37-32\lib\site-packages\pluggy\callers.py", line 180, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "c:\users\sb\appdata\local\programs\python\python37-32\lib\site-packages\pytest_concurrent.py", line 126, in pytest_runtestloop
INTERNALERROR> _run_items(mode=mode, items=ungrouped_items, session=session, workers=workers)
INTERNALERROR> File "c:\users\sb\appdata\local\programs\python\python37-32\lib\site-packages\pytest_concurrent.py", line 164, in _run_items
INTERNALERROR> item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR> File "c:\users\sb\appdata\local\programs\python\python37-32\lib\site-packages\pluggy\hooks.py", line 258, in call
INTERNALERROR> return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR> File "c:\users\sb\appdata\local\programs\python\python37-32\lib\site-packages\pluggy\manager.py", line 67, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File "c:\users\sb\appdata\local\programs\python\python37-32\lib\site-packages\pluggy\manager.py", line 61, in
INTERNALERROR> firstresult=hook.spec_opts.get('firstresult'),
INTERNALERROR> File "c:\users\sb\appdata\local\programs\python\python37-32\lib\site-packages\pluggy\callers.py", line 201, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File "c:\users\sb\appdata\local\programs\python\python37-32\lib\site-packages\pluggy\callers.py", line 76, in get_result
INTERNALERROR> raise ex[1].with_traceback(ex[2])
INTERNALERROR> File "c:\users\sb\appdata\local\programs\python\python37-32\lib\site-packages\pluggy\callers.py", line 175, in _multicall
INTERNALERROR> next(gen) # first yield
INTERNALERROR> File "c:\users\sb\appdata\local\programs\python\python37-32\lib\site-packages\pytest_reportportal\listener.py", line 32, in pytest_runtest_protocol
INTERNALERROR> self.PyTestService.start_pytest_item(item)
INTERNALERROR> File "c:\users\sb\appdata\local\programs\python\python37-32\lib\site-packages\pytest_reportportal\service.py", line 194, in start_pytest_item
INTERNALERROR> part = self._start_stack.pop(0)
INTERNALERROR> IndexError: pop from empty list

_get_item_name fail if test name is longer then 256 symb

    @staticmethod
    def _get_item_name(test_item):
        name = test_item._rp_name
        if len(name) > 256:
            name = name[:256]
            test_item.warn(
                'C1',
                'Test node ID was truncated to "{}" because of name size '
                'constrains on reportportal'.format(name)
            )
        return name

warn method takes 2 elements but was passed 3. I got this error in combination with xdist and huge bdd outline param string. Also this test freezes parallel test run.

Pytest reports 'Service already stopped' and causes incomplete launch be uploaded

Hello,

I've tried to configured this project 'https://github.com/savoirfairelinux/num2words.git'.
The issue I got after running command 'pytest' is:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "c:\python27\lib\threading.py", line 801, in __bootstrap_inner
    self.run()
  File "c:\python27\lib\threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "c:\python27\lib\site-packages\reportportal_client\service_async.py", line 86, in _monitor
    self.handle(record)
  File "c:\python27\lib\site-packages\reportportal_client\service_async.py", line 54, in handle
    handler(record)
  File "c:\python27\lib\site-packages\reportportal_client\service_async.py", line 208, in process_item
    self.terminate(nowait=True)
  File "c:\python27\lib\site-packages\reportportal_client\service_async.py", line 153, in terminate
    raise Error("Service already stopped.")
Error: Service already stopped.

My environment:

  • Python 2.7.13 (Windows 10 x64)
  • pytest (3.6.2)
  • pytest-reportportal (1.0.3)
  • reportportal-client (3.1.0)

Screenshots:
image
image

These pacakges are installed via pip.

I think there should be a bug in our library.
Please help review and fix ASAP.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.