Skip to main content

agent-python-pytest

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.3.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.3.2
File Size Uploaded Provenance Actions
pytest-reportportal-5.3.2.tar.gz 26.6 kB Without provenance Details for pytest-reportportal-5.3.2.tar.gz

Built distribution (wheel)

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

Total release size: 53.8 kB

Release files / pytest-reportportal-5.3.2.tar.gz

Download URL pytest-reportportal-5.3.2.tar.gz
Size 26.6 kB
Tags Source
SHA-256 checksum
How to use checksums
06d022a32aa7d60b2998e72710db0714610eee43c1e3384afc29805c0c2eb9a4
BLAKE2b-256 checksum
How to use checksums
faff6648f503274e9a0e054f645438f0b2f6b845c30ce58aae0c2ce7e3702e0b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

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

Download URL pytest_reportportal-5.3.2-py2.py3-none-any.whl
Size 27.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
f97b9df3bbf34a19df3a7b47d00bcc0872472d1dbcf7a987ac8007cda0980a52
BLAKE2b-256 checksum
How to use checksums
2fcfc0c09d32875af2ea9991538c27472df8a049d46960982711cb7b78a37879
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Security for pytest-reportportal 5.3.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

5.3.2 This release

2 release files No provenance

0.2.4

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