Registry / testing / reportportal-client

reportportal-client

JSON →
library5.7.10pypypi✓ verified 24d ago

The reportportal-client is a Python client library for integrating test automation results with ReportPortal v5. It provides functionalities to manage launches, test items, and logs, including attachments. The current version is 5.7.4, and the library generally sees frequent minor updates, often several per month.

pip install reportportal-client
INSTALL
IMPORT
SIG · REPORTPORTAL-CLIEN
R
reportportal-client
testingpythonv5.7.10
Install
4.4s avg
Import
921ms
Disk
30MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v5.7.10 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.974s · 30.5MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 4.4s · import 0.868s · 33MB
30MB installed
● package 30MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

RPClient
from reportportal_client import RPClient
import RPClient
RPClient is the main entry point for interacting with the ReportPortal API.
RPLogHandler
from reportportal_client import RPLogHandler
from reportportal_client.logs import RPLogHandler
RPLogHandler is used for integrating with Python's standard logging module. Its path moved to the top-level package.
RPLogger
from reportportal_client import RPLogger
from reportportal_client.logs import RPLogger
RPLogger is a custom logging class extending Python's Logger, often used in conjunction with RPLogHandler. Its path moved to the top-level package.
timestamp
from reportportal_client.helpers import timestamp
A helper function to generate timestamps in the format expected by ReportPortal.

This quickstart demonstrates the basic usage of the ReportPortal Python client, including starting and finishing a launch, creating test items (steps), logging messages, and attaching files. It also shows how to integrate the client with Python's standard logging module using `RPLogger` and `RPLogHandler`. Environment variables are used for ReportPortal configuration (RP_ENDPOINT, RP_PROJECT, RP_API_KEY) for secure execution. The `client.terminate()` call in the finally block is essential for asynchronous operations.

import os import subprocess from mimetypes import guess_type import logging from reportportal_client import RPClient, RPLogger, RPLogHandler from reportportal_client.helpers import timestamp # Configure logging for the client itself (optional, but good practice) logging.basicConfig(level=logging.DEBUG) # ReportPortal configuration from environment variables endpoint = os.environ.get('RP_ENDPOINT', 'http://localhost:8080/api/v1') project = os.environ.get('RP_PROJECT', 'default_personal') api_key = os.environ.get('RP_API_KEY', 'YOUR_API_KEY') # Get from your ReportPortal User Profile launch_name = 'Example Launch' launch_doc = 'Basic example of using reportportal-client.' # Set up ReportPortal logger logging.setLoggerClass(RPLogger) rp_logger = logging.getLogger(__name__) rp_logger.setLevel(logging.INFO) rp_logger.addHandler(RPLogHandler(endpoint=endpoint, project=project, api_key=api_key, launch_uuid=None)) try: # Initialize RPClient client = RPClient(endpoint=endpoint, project=project, api_key=api_key) # Start log upload thread (for async mode) client.start() # Start a new launch launch = client.start_launch( name=launch_name, start_time=timestamp(), description=launch_doc, attributes=[{'key': 'client', 'value': 'python'}, {'value', 'example'}] ) launch_uuid = launch.uuid rp_logger.info(f'Launch started with UUID: {launch_uuid}') # Start a test item (e.g., a test case or suite) test_item = client.start_test_item( name='Test Case 1', description='First Test Case', start_time=timestamp(), attributes=[{'key': 'suite', 'value': 'smoke'}], item_type='STEP', launch_uuid=launch_uuid ) test_item_uuid = test_item.uuid rp_logger.info(f'Test Item started with UUID: {test_item_uuid}') # Log messages client.log(time=timestamp(), message='Hello from ReportPortal Client!', level='INFO', launch_uuid=launch_uuid, item_uuid=test_item_uuid) rp_logger.warning('This is a warning log using the standard Python logger.', attachment={ 'name': 'warning.txt', 'data': b'This is an attached text file content.', 'mime': 'text/plain' }) # Simulate a subprocess call and attach output try: output = subprocess.check_output(['ls', '-l'], stderr=subprocess.STDOUT) client.log(time=timestamp(), message='ls -l output', level='DEBUG', launch_uuid=launch_uuid, item_uuid=test_item_uuid, attachment={ 'name': 'ls_output.txt', 'data': output, 'mime': 'text/plain' }) except subprocess.CalledProcessError as e: client.log(time=timestamp(), message=f'Command failed: {e.output.decode()}', level='ERROR', launch_uuid=launch_uuid, item_uuid=test_item_uuid) # Finish the test item client.finish_test_item(item_uuid=test_item_uuid, end_time=timestamp(), status='PASSED', launch_uuid=launch_uuid) rp_logger.info(f'Test Item {test_item_uuid} finished.') # Finish the launch client.finish_launch(launch_uuid=launch_uuid, end_time=timestamp(), status='PASSED') rp_logger.info(f'Launch {launch_uuid} finished.') except Exception as e: rp_logger.error(f'An error occurred: {e}') finally: # It's crucial to call terminate() to ensure all pending requests are sent to ReportPortal client.terminate() rp_logger.info('Client terminated, all pending logs sent.')
Debug
Known issues
breakingPython 3.8 support was officially removed in version 5.7.0. Projects using Python 3.8 or older will need to upgrade their Python version to use recent client versions.
fix
Upgrade Python to version 3.9 or newer.
affects: >=5.7.0
breakingThe `log_manager.py` module, which included classes like `RPLogger` and `RPLogHandler`, was removed in version 5.7.0. These classes are now directly available under the top-level `reportportal_client` package.
fix
Update import statements from `from reportportal_client.log_manager import ...` to `from reportportal_client import ...`.
affects: >=5.7.0
gotchaThe configuration parameter `log_batch_payload_size` was renamed to `log_batch_payload_limit` in version 5.6.7. If you use a custom configuration file or environment variables with the old name, it will no longer be recognized.
fix
Update your ReportPortal configuration (e.g., `pytest.ini`, environment variables) to use `log_batch_payload_limit` instead of `log_batch_payload_size` for controlling the maximum payload size of asynchronous log requests.
affects: >=5.6.7
breakingThe `NOT_FOUND` constant was removed in version 5.6.3 as it caused infinite issues according to release notes.
fix
Review your code for any usage of `NOT_FOUND` constant and remove or replace it with appropriate error handling or status checks.
affects: >=5.6.3
gotchaWhen using the client in asynchronous mode (which is default for `RPClient`), it is crucial to call `client.terminate()` after all test operations are complete. Failing to do so may result in unsent logs or test items, as pending requests may not be flushed to the ReportPortal server.
fix
Always ensure `client.terminate()` is called in a `finally` block or at the end of your test execution logic.
affects: All versions with async client
gotchaReportPortal supports both API Key and OAuth 2.0 Password Grant authentication. If both API key and OAuth parameters are provided, OAuth 2.0 authentication will take precedence. Ensure your configuration correctly specifies the desired authentication method.
fix
Provide either the `api_key` or a complete set of OAuth 2.0 parameters (`rp_oauth_uri`, `rp_oauth_username`, `rp_oauth_password`, `rp_oauth_client_id`). Avoid providing both if you intend to use API Key authentication.
affects: All 5.x versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'reportportal-client'
Python import statements require module names to use underscores (`_`) instead of hyphens (`-`).
fix
from reportportal_client import ReportPortalClient
TypeError: __init__() missing 1 required positional argument: 'base_url'
The `ReportPortalClient` constructor requires mandatory arguments such as `base_url`, `project`, and `api_key` to be provided.
fix
from reportportal_client import ReportPortalClient
rp_client = ReportPortalClient(base_url='http://your-reportportal-url:8080', project='YOUR_PROJECT_NAME', api_key='YOUR_API_KEY')
KeyError: 'name'
Methods like `start_launch` or `start_test_item` expect a dictionary containing a mandatory 'name' key, which was missing.
fix
launch_data = {'name': 'My Launch Name', 'start_time': 1678886400000}
rp_client.start_launch(**launch_data)
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionRefusedError(111, 'Connection refused'))
The ReportPortal server specified by the `base_url` is unreachable, the URL is incorrect, or the server is not running.
fix
from reportportal_client import ReportPortalClient
# Verify that 'base_url' is correct and accessible, and the ReportPortal server is running.
rp_client = ReportPortalClient(base_url='http://correct-reportportal-url:8080', project='YOUR_PROJECT_NAME', api_key='YOUR_API_KEY')
Upgrade
Version history
5.7.10latest on PyPI · released Aug 5, 2026
Audit
Dependencies
aiohttprequiredUsed for asynchronous HTTP requests to the ReportPortal API. Its version was updated in 5.7.2.
Agent activity
21 hits · last 30 days
node
18
OpenAI (training)
2
Resources
reportportal-client — pip install reportportal-client · libregistry