Skip to content

INTERNALERROR due to pytest.exit within fixture #390

@SasNst

Description

@SasNst

Describe the bug
When this plugin is active and I call pytest.exit() within a pytest fixture I get the following error and the testrun hangs indefinitely:

demo/test_exit.py
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/home/demo/lib/python3.10/site-packages/_pytest/main.py", line 283, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "/home/demo/lib/python3.10/site-packages/_pytest/main.py", line 337, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "/home/demo/lib/python3.10/site-packages/pluggy/_hooks.py", line 513, in __call__
INTERNALERROR>     return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
INTERNALERROR>   File "/home/demo/lib/python3.10/site-packages/pluggy/_manager.py", line 120, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>   File "/home/demo/lib/python3.10/site-packages/pluggy/_callers.py", line 182, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/home/demo/lib/python3.10/site-packages/pluggy/_result.py", line 100, in get_result
INTERNALERROR>     raise exc.with_traceback(exc.__traceback__)
INTERNALERROR>   File "/home/demo/lib/python3.10/site-packages/pluggy/_callers.py", line 167, in _multicall
INTERNALERROR>     teardown.throw(outcome._exception)
INTERNALERROR>   File "/home/demo/lib/python3.10/site-packages/_pytest/logging.py", line 803, in pytest_runtestloop
INTERNALERROR>     return (yield)  # Run all the tests.
INTERNALERROR>   File "/home/demo/lib/python3.10/site-packages/pluggy/_callers.py", line 167, in _multicall
INTERNALERROR>     teardown.throw(outcome._exception)
INTERNALERROR>   File "/home/demo/lib/python3.10/site-packages/_pytest/terminal.py", line 673, in pytest_runtestloop
INTERNALERROR>     result = yield
INTERNALERROR>   File "/home/demo/lib/python3.10/site-packages/pluggy/_callers.py", line 103, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/home/demo/lib/python3.10/site-packages/_pytest/main.py", line 362, in pytest_runtestloop
INTERNALERROR>     item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR>   File "/home/demo/lib/python3.10/site-packages/pluggy/_hooks.py", line 513, in __call__
INTERNALERROR>     return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
INTERNALERROR>   File "/home/demo/lib/python3.10/site-packages/pluggy/_manager.py", line 120, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>   File "/home/demo/lib/python3.10/site-packages/pluggy/_callers.py", line 156, in _multicall
INTERNALERROR>     teardown[0].send(outcome)
INTERNALERROR>   File "/home/demo/lib/python3.10/site-packages/pytest_reportportal/plugin.py", line 280, in pytest_runtest_protocol
INTERNALERROR>     service.finish_pytest_item(item)
INTERNALERROR>   File "/home/demo/lib/python3.10/site-packages/pytest_reportportal/service.py", line 125, in wrap
INTERNALERROR>     return func(*args, **kwargs)
INTERNALERROR>   File "/home/demo/lib/python3.10/site-packages/pytest_reportportal/service.py", line 814, in finish_pytest_item
INTERNALERROR>     self._finish_step(self._build_finish_step_rq(leaf))
INTERNALERROR>   File "/home/demo/lib/python3.10/site-packages/pytest_reportportal/service.py", line 750, in _build_finish_step_rq
INTERNALERROR>     status = leaf['status']
INTERNALERROR> KeyError: 'status'

Steps to Reproduce
Steps to reproduce the behavior:

  1. Run the following example code (with --reportportal and other necessary params of course)
import pytest


@pytest.fixture
def fixture_demo():
    print("Fixture called")
    pytest.exit("Some Message")


def test_exit(fixture_demo):
    assert True

Expected behavior
Run the tests and exit gracefully, finish the test run in reportportal.

Actual behavior
INTERNALERROR and hangs until cancelled by keyboard interrupt. Launch in reportportal is running until timeout or ended manually.

Package versions
reportportal-client: 5.5.10
pytest-reportportal: 5.4.7

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions