reportportal / agent-python-pytest

Framework integration with PyTest
Apache License 2.0
94 stars 102 forks source link

integration between ReportPortal and PyTest seems broken #315

Closed bchmura-thinxnet closed 2 years ago

bchmura-thinxnet commented 2 years ago

Describe the bug Running an example integration of reportportal and pytest leads to a crash with multiple INTERNALERRORs

Steps to Reproduce Steps to reproduce the behavior:

  1. Create a new RP project 'test_project'
  2. Create pytest.ini

`[pytest] rp_uuid = 993cd4f8-754e-4363-af06-0fcd5e53379c rp_endpoint = # ... rp_launch = testlaunch rp_project = test_project

markers = simple: Simple tests`

(the rp_endpoint has been edited out, the uuid has been newly generated for this post's sake)

  1. Create requirements.txt

pytest pytest-reportportal reportportal-client

  1. Create simple_test.py

`import logging 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

def test_one(): """ Description of the test case which will be sent to Report Portal """ pass `

  1. Run test using:

python3 -m pytest -sv --reportportal

Expected behavior A test run shows up in ReportPortal.

Actual behavior =========================================== test session starts ============================================ platform linux -- Python 3.10.5, pytest-7.1.2, pluggy-1.0.0 -- /home/bartoszc/PycharmProjects/ReportPortal/venv/bin/python3 cachedir: .pytest_cache rootdir: /home/bartoszc/PycharmProjects/ReportPortal, configfile: pytest.ini plugins: reportportal-5.1.2 collected 1 item INTERNALERROR> Traceback (most recent call last): INTERNALERROR> File "/home/bartoszc/PycharmProjects/ReportPortal/venv/lib/python3.10/site-packages/_pytest/main.py", line 268, in wrap_session INTERNALERROR> session.exitstatus = doit(config, session) or 0 INTERNALERROR> File "/home/bartoszc/PycharmProjects/ReportPortal/venv/lib/python3.10/site-packages/_pytest/main.py", line 322, in _main INTERNALERROR> config.hook.pytest_runtestloop(session=session) INTERNALERROR> File "/home/bartoszc/PycharmProjects/ReportPortal/venv/lib/python3.10/site-packages/pluggy/_hooks.py", line 265, in __call__ INTERNALERROR> return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult) INTERNALERROR> File "/home/bartoszc/PycharmProjects/ReportPortal/venv/lib/python3.10/site-packages/pluggy/_manager.py", line 80, in _hookexec INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult) INTERNALERROR> File "/home/bartoszc/PycharmProjects/ReportPortal/venv/lib/python3.10/site-packages/pluggy/_callers.py", line 60, in _multicall INTERNALERROR> return outcome.get_result() INTERNALERROR> File "/home/bartoszc/PycharmProjects/ReportPortal/venv/lib/python3.10/site-packages/pluggy/_result.py", line 60, in get_result INTERNALERROR> raise ex[1].with_traceback(ex[2]) INTERNALERROR> File "/home/bartoszc/PycharmProjects/ReportPortal/venv/lib/python3.10/site-packages/pluggy/_callers.py", line 39, in _multicall INTERNALERROR> res = hook_impl.function(*args) INTERNALERROR> File "/home/bartoszc/PycharmProjects/ReportPortal/venv/lib/python3.10/site-packages/_pytest/main.py", line 347, in pytest_runtestloop INTERNALERROR> item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem) INTERNALERROR> File "/home/bartoszc/PycharmProjects/ReportPortal/venv/lib/python3.10/site-packages/pluggy/_hooks.py", line 265, in __call__ INTERNALERROR> return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult) INTERNALERROR> File "/home/bartoszc/PycharmProjects/ReportPortal/venv/lib/python3.10/site-packages/pluggy/_manager.py", line 80, in _hookexec INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult) INTERNALERROR> File "/home/bartoszc/PycharmProjects/ReportPortal/venv/lib/python3.10/site-packages/pluggy/_callers.py", line 60, in _multicall INTERNALERROR> return outcome.get_result() INTERNALERROR> File "/home/bartoszc/PycharmProjects/ReportPortal/venv/lib/python3.10/site-packages/pluggy/_result.py", line 60, in get_result INTERNALERROR> raise ex[1].with_traceback(ex[2]) INTERNALERROR> File "/home/bartoszc/PycharmProjects/ReportPortal/venv/lib/python3.10/site-packages/pluggy/_callers.py", line 34, in _multicall INTERNALERROR> next(gen) # first yield INTERNALERROR> File "/home/bartoszc/PycharmProjects/ReportPortal/venv/lib/python3.10/site-packages/pytest_reportportal/plugin.py", line 222, in pytest_runtest_protocol INTERNALERROR> service.start_pytest_item(item) INTERNALERROR> File "/home/bartoszc/PycharmProjects/ReportPortal/venv/lib/python3.10/site-packages/pytest_reportportal/service.py", line 651, in start_pytest_item INTERNALERROR> item_id = self._start_step(self._build_start_step_rq(current_leaf)) INTERNALERROR> File "/home/bartoszc/PycharmProjects/ReportPortal/venv/lib/python3.10/site-packages/pytest_reportportal/service.py", line 623, in _start_step INTERNALERROR> return self.rp.start_test_item(**step_rq) INTERNALERROR> File "/home/bartoszc/PycharmProjects/ReportPortal/venv/lib/python3.10/site-packages/reportportal_client/client.py", line 379, in start_test_item INTERNALERROR> verify_ssl=self.verify_ssl).make() INTERNALERROR> File "/home/bartoszc/PycharmProjects/ReportPortal/venv/lib/python3.10/site-packages/reportportal_client/core/rp_requests.py", line 73, in make INTERNALERROR> return RPResponse(self.session_method( INTERNALERROR> File "/home/bartoszc/PycharmProjects/ReportPortal/venv/lib/python3.10/site-packages/requests/sessions.py", line 635, in post INTERNALERROR> return self.request("POST", url, data=data, json=json, **kwargs) INTERNALERROR> File "/home/bartoszc/PycharmProjects/ReportPortal/venv/lib/python3.10/site-packages/requests/sessions.py", line 573, in request INTERNALERROR> prep = self.prepare_request(req) INTERNALERROR> File "/home/bartoszc/PycharmProjects/ReportPortal/venv/lib/python3.10/site-packages/requests/sessions.py", line 484, in prepare_request INTERNALERROR> p.prepare( INTERNALERROR> File "/home/bartoszc/PycharmProjects/ReportPortal/venv/lib/python3.10/site-packages/requests/models.py", line 371, in prepare INTERNALERROR> self.prepare_body(data, files, json) INTERNALERROR> File "/home/bartoszc/PycharmProjects/ReportPortal/venv/lib/python3.10/site-packages/requests/models.py", line 511, in prepare_body INTERNALERROR> body = complexjson.dumps(json, allow_nan=False) INTERNALERROR> File "/usr/lib/python3.10/json/__init__.py", line 238, in dumps INTERNALERROR> **kw).encode(obj) INTERNALERROR> File "/usr/lib/python3.10/json/encoder.py", line 199, in encode INTERNALERROR> chunks = self.iterencode(o, _one_shot=True) INTERNALERROR> File "/usr/lib/python3.10/json/encoder.py", line 257, in iterencode INTERNALERROR> return _iterencode(o, 0) INTERNALERROR> File "/usr/lib/python3.10/json/encoder.py", line 179, in default INTERNALERROR> raise TypeError(f'Object of type {o.__class__.__name__} ' INTERNALERROR> TypeError: Object of type _PresenceSentinel is not JSON serializable

Package versions Include version info of the following packages: reportportal-client, pytest-reportportal pytest-reportportal: 5.1.2 reportporal-client: 5.2.3

Additional context

bchmura-thinxnet commented 2 years ago

Interestingly enough - after regenerating the rp_uuid several times and going through the project setup (clicking on submit in all possible categories) the issue seems to have gone away. The issue was present with the rp_uuid as posted in the initial bug report though. Not sure if that may have caused it in any way.

bchmura-thinxnet commented 2 years ago

I've found the problem. The URL changed from http to https :facepalm: