Pytest ReportPortal Agent
pytest-reportportal is a Pytest plugin that serves as an agent for reporting test results to the ReportPortal test automation dashboard. It enables real-time reporting, detailed logs, and execution data analysis for Python tests run with Pytest. The library, currently at version 5.6.6, receives frequent minor updates to improve functionality, fix bugs, and maintain compatibility with Python and the ReportPortal client.
Warnings
- breaking Python 3.8 support was removed starting from `pytest-reportportal` version 5.6.0. Users on Python 3.8 or older must upgrade their Python version to use recent agent versions.
- deprecated The `rp_uuid` configuration parameter for authentication has been removed since version 5.5.3. It was replaced by `rp_api_key` for API Key authentication or a set of `rp_oauth_*` parameters for OAuth 2.0 Password Grant.
- breaking The `retries` parameter for ReportPortal client configuration was removed in version 5.6.0. This parameter is no longer supported and will cause configuration errors if present.
- gotcha Using `pytest-xdist` with `pytest-reportportal` can lead to issues, especially with hierarchy reporting. While some fixes for `xdist` compatibility have been introduced (e.g., for code reference generation), complex scenarios might still exhibit unexpected behavior or limitations.
- gotcha Configuration parameters can be overridden by environment variables and command-line arguments. Environment variables (e.g., `RP_API_KEY`) take precedence over `pytest.ini` settings, and command-line arguments (e.g., `--rp-launch`) take precedence over both. This can lead to unexpected behavior if not managed carefully.
Install
-
pip install pytest-reportportal
Imports
- RPLogger
from reportportal_client import RPLogger
- RPLogHandler
from reportportal_client import RPLogHandler
Quickstart
import pytest
import os
# --- pytest.ini (simulated content for quickstart) ---
# [pytest]
# rp_endpoint = http://localhost:8080
# rp_project = default_personal
# rp_api_key = your_api_key_from_reportportal_profile
# rp_launch = MyPytestLaunch
# To run this example:
# 1. Ensure ReportPortal is running (e.g., via Docker).
# 2. Set environment variables or create a pytest.ini file:
# export RP_ENDPOINT="http://localhost:8080"
# export RP_PROJECT="default_personal"
# export RP_API_KEY="your_api_key"
# 3. Save the test below as `test_example.py`.
# 4. Run from your terminal: `pytest --reportportal test_example.py`
def test_passing_example():
assert True
def test_failing_example():
assert False
@pytest.mark.skip(reason="demonstrating skip")
def test_skipped_example():
pass