Skip to main content
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/

Metadata

Release files for pytest-reportportal 5.4.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-reportportal 5.4.2
File Size Uploaded
pytest_reportportal-5.4.2.tar.gz 26.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-reportportal 5.4.2
File Interpreter ABI Platform
pytest_reportportal-5.4.2-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 53.9 kB

Release files / pytest_reportportal-5.4.2.tar.gz

Download URL pytest_reportportal-5.4.2.tar.gz
Size 26.7 kB
Tags Source
SHA-256 checksum
How to use checksums
7ed5489a79da038b8a1029d7d3a1aef023bdbe9c77939163dde6284023cf8505
BLAKE2b-256 checksum
How to use checksums
8557b7609755ec6e95562dd980fd0917f96d82421f96d54b6146a27fb539a102
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.5

Release files / pytest_reportportal-5.4.2-py2.py3-none-any.whl

Download URL pytest_reportportal-5.4.2-py2.py3-none-any.whl
Size 27.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
e261c645490881c05ceec3f7968272917ee535576c2d802bec671895742cacc5
BLAKE2b-256 checksum
How to use checksums
49ac9f76cd7bcb70ad4533ae1fd81ae82153f76fd96a9879c4e3c32eac6ad01c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.5

Release history Release notifications | RSS feed

5.6.11

2 release files

5.6.10

2 release files

5.6.9

2 release files

5.6.8

2 release files

5.6.7

2 release files

5.6.6

2 release files

5.6.5

2 release files

5.6.4

2 release files

5.6.3

2 release files

5.6.2

2 release files

5.6.1

2 release files

5.6.0

2 release files

5.5.4

2 release files

5.5.3

2 release files

5.5.2

2 release files

5.5.1

2 release files

5.5.0

2 release files

5.4.7

2 release files

5.4.6

2 release files

5.4.5

2 release files

5.4.4

2 release files

5.4.3

2 release files

This release

5.4.2 This release

2 release files

5.4.1

2 release files

5.4.0

2 release files

5.3.2

2 release files

5.3.1

2 release files

5.3.0

2 release files

5.2.2

2 release files

5.2.1

2 release files

5.2.0

2 release files

5.1.9

2 release files

5.1.8

2 release files

5.1.7

2 release files

5.1.6

2 release files

5.1.5

2 release files

5.1.4

2 release files

5.1.3

2 release files

5.1.2

2 release files

5.1.1

2 release files

5.1.0

2 release files

5.0.12

2 release files

5.0.11

2 release files

5.0.10

2 release files

5.0.9

2 release files

5.0.8

2 release files

5.0.7

2 release files

5.0.6

2 release files

5.0.5

2 release files

5.0.4

2 release files

5.0.3

2 release files

5.0.2

2 release files

5.0.1

2 release files

5.0.0

2 release files

1.10.1

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

1 release file

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.2.4

0.2.3

1 release file

0.2.2

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page