Skip to main content

Agent for Reporting results of tests to the Report Portal

Project description

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/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-reportportal-5.4.0.tar.gz (26.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_reportportal-5.4.0-py2.py3-none-any.whl (27.2 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pytest-reportportal-5.4.0.tar.gz.

File metadata

  • Download URL: pytest-reportportal-5.4.0.tar.gz
  • Upload date:
  • Size: 26.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for pytest-reportportal-5.4.0.tar.gz
Algorithm Hash digest
SHA256 b4309c48fc238d2f1439a97aeee0748cf00b9a219f9b729080c42aa945a3c641
MD5 01166dc7217f7cd3107e90435c0c35ba
BLAKE2b-256 8c4388285d66827ff311b2abc433a18169ce7fc8cd593a49a0dbb18b028b4c7a

See more details on using hashes here.

File details

Details for the file pytest_reportportal-5.4.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_reportportal-5.4.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 f2a9f437b6751d5a0bbe2ff68e12966c8c449401ee5f8f9078f39a9e3de92af3
MD5 e4cf742a01f808d10f4a28e10c1bc7bd
BLAKE2b-256 ddba82c62afccc6ce1387ba3a45d1475c334585ce51df9c49f573d544b243f9e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page