Skip to main content

Important: this is draft version under development.

Pytest plugin for reporting test results of Pytest to the ‘Reportal Portal’.

Usage

Installation

To install pytest plugin execute next command in a terminal:

pip install pytest-reportportal

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_uuid - value could be found in the User Profile section

  • rp_project - name of project in Report Potal

  • rp_endpoint - address of Report Portal Server

Example of pytest.ini:

[pytest]
rp_uuid = fb586627-32be-47dd-93c1-678873458a5f
rp_endpoint = http://192.168.1.10:8080
rp_project = user_personal
rp_launch = AnyLaunchName
rp_launch_tags = 'PyTest' 'Smoke'
rp_launch_description = 'Smoke test'

The following parapmeters are optional:

  • rp_launch = AnyLaunchName - launch name (could be overriden by pytest –rp-launch option, default value is ‘Pytest Launch’)

  • rp_launch_tags = 'PyTest' 'Smoke' - list of tags

  • rp_launch_description = 'Smoke test' - launch description

  • rp_log_batch_size = 20 - size of batch log request

Examples

For logging of the test item flow to Report Portal, please, use the python logging handler provided by plugin like bellow:

import logging
# Import Report Portal logger and handler to the test module.
from pytest_reportportal import RPLogger, RPLogHandler
# Setting up a logging.
logging.setLoggerClass(RPLogger)
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
# Create handler for Report Portal.
rp_handler = RPLogHandler()
# Set INFO level for Report Portal handler.
rp_handler.setLevel(logging.INFO)
# Add handler to the logger.
logger.addHandler(rp_handler)


# In this case only INFO messages will be sent to the Report Portal.
def test_one():
    logger.info("Case1. Step1")
    x = "this"
    logger.info("x is: %s", x)
    assert 'h' in x

    # Message with an attachment.
    import subprocess
    free_memory = subprocess.check_output("free -h".split())
    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 Report Portal.
    logger.debug("Case1. Debug message")

Plugin can report doc-strings of tests as descriptions:

def test_one():
    """
    Description of the test case which will be sent to Report Portal
    """
    pass

Pytest markers will be attached as tags to Report Portal items. In the following example tags ‘linux’ and ‘win32’ will be used:

import pytest

@pytest.mark.win32
@pytest.mark.linux
def test_one():
    pass

Launching

To run test with Report Portal you can specify name of launch:

py.test ./tests --rp-launch AnyLaunchName

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-1.0.0.tar.gz (7.4 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-1.0.0-py2.py3-none-any.whl (9.5 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

File hashes

Hashes for pytest-reportportal-1.0.0.tar.gz
Algorithm Hash digest
SHA256 41fe371de674620d520cce7ada309d6de02144dd4495784ef5c83c8e6c419362
MD5 9d6893f0d43610a5f1f1dbfaae3d1ab8
BLAKE2b-256 77e4f910891e8ebe133f3dca4095f14ecf2095103faa0d67ee92c2f01141d8aa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytest_reportportal-1.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 925bfb9cbfb9a4051b78c44337d75834780ad3ac21bb7ef616812c8c715e6b0d
MD5 32eb045a5715b4d2966bc3841f8bc884
BLAKE2b-256 3e389d4563bdac96c8ae53c94588737cb9906061e94d6f89bf4d158fdb88c046

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